Phil
Phil

Reputation: 1662

Writing text within a list

I am trying to write my code to be as semantic as possible and am wondering if it is more correct to write text within a list item as...

<li>
    <p>This is my text</p>
    <p>This is another bit of text</p>
</li>

or

<li>
    This is my text
    <br />
    <br />
    This is another bit of text
</li>

Thanks for any help.

Upvotes: 2

Views: 104

Answers (2)

Bas Slagter
Bas Slagter

Reputation: 9929

Just do as you would do as if you had some text directly in the body. So, use h1, h2 etc for headings and use p for paragraphs. So to answer your question, I would go for option one and use <br/> within the text if you need so but wrap it with the p element.

Also, you can take a look at the brand new html 5 elements to give your text more meaning.

Upvotes: 1

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143219

If "your texts" are paragraphs, they should go into p tags, when it comes to semantics.

Upvotes: 1

Related Questions