Can we use any other TAG inside <ul> along with <li>?

Jitendra Vyas picture Jitendra Vyas · Jan 29, 2010 · Viewed 61.6k times · Source

Can we use any other TAG in <ul> along with <li>?

like

<ul>
Some text here or <p>Some text here<p> etc
<li>item 1</li>
Some text here or <p>Some text here<p> etc
<li>item 1</li>
</ul>

Answer

Jonny Haynes picture Jonny Haynes · Jan 29, 2010

For your code to be valid you can't put any tag inside a <ul> other than an <li>.

You can however, put any block level element inside the <li>, like so:

<ul>
        <li>
            <h2>...</h2>
            <p>...</p>
            <p>...</p>
        </li>
</ul>