Does hand-created plain text notes have <p> tags by default?

I apologize if it’s been asked before, the topic is hard to search.

So, over the last decade, I’ve manually created thousands of notes by simply typing. I never thought about whether they have <p> tags or not. Until recently when I’m trying to add some margins between paragraphs, like this:

As you can see, on the right side I have 3 lines of “lorem ipsum” text, separated by line breaks. My goal is to visually separate them into 3 paragraphs, but apparently p {} won’t work.

Now I doubt there are simply no <p> tags at all, but I don’t know how to view the raw html to confirm. Any suggestions? Thanks.

You can check the raw HTML by using this button (the exact position may vary depending on the version) or clicking Ctrl+Shift+X

The current tag for line breaks is <br>, while it used to be <div> for older versions (until Anki 2.1.40 I think)

To add margins between paragraphs, maybe you could use something like:

br {
  display: block; /* makes it have a width */
  content: ""; /* clears default height */
  margin-top: 25px; 
}
div {
  margin-top: 25px;
}
3 Likes

I checked my html, and it’s div. I have v⁨2.1.60 so I should have br? But it’s still div, do you think it’s because my “note type” is an old one?

Anyway, your code works on both cases, and thank you so much!

Weirdly I found the raw html of the card in my screenshot contains both double and triple divs which seems inconsistent:

<div>
  <div>
    Lorem ipsum dolor sit amet consectetur adipisicing elit. Et obcaecati autem
    tempore, nulla dicta maiores cumque, aliquid sunt unde accusamus maxime
    quidem est! Similique commodi corporis maiores quod illum reiciendis.
  </div>
</div>
<div>
  <div>
    <div>
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Et obcaecati
      autem tempore, nulla dicta maiores cumque, aliquid sunt unde accusamus
      maxime quidem est! Similique commodi corporis maiores quod illum
      reiciendis.
    </div>
  </div>
</div>
<div>
  <div>
    <div>
      Lorem ipsum dolor sit amet consectetur adipisicing elit. Et obcaecati
      autem tempore, nulla dicta maiores cumque, aliquid sunt unde accusamus
      maxime quidem est! Similique commodi corporis maiores quod illum
      reiciendis.
    </div>
  </div>
</div>

But your code still works as intended because of vertical margin collapse, which is amazing!

1 Like

Update: did some tests, it seems that it’s br by default, but divs are generated when I use ctrl-shift-v to paste in some texts. Styles are stripped by ctrl-shift-v but the div tags are left. Anyway, thanks!

The tags for line breaks do not depend on the Anki version you open the notes with, rather on the version you were using when you added them. Prior to Anki 2.1.41, Anki used to add <div> for line breaks, while from 2.1.41 onwards it adds <br> .

That depends on the HTML of the source text you are copying. If I remember correctly, using Ctrl+Shift+V will strip most HTML except <div> and <br> tags.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.