Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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> 
like image 727
Jitendra Vyas Avatar asked Jan 29 '10 10:01

Jitendra Vyas


People also ask

What elements can go inside a UL?

HTML ul element can reside within APPLET, BLOCKQUOTE, BODY, BUTTON, CENTER, DD, DEL, DIV, FIELDSET, FORM, IFRAME, INS, LI, MAP, NOFRAMES, NOSCRIPT, OBJECT, TD, TH.

Can we use P tag inside UL?

The short answer is that ol elements are not legally allowed inside p elements.

Can Li tag be used without UL?

If it gets displayed correctly, it's only a matter of luck. As you seem to define dangerous by "break in browsers for the end user's ability to view the page as intended", then yes it's dangerous.

Can we use UL inside Li?

This took me a little while to understand because I wrapped my inner ul in its own li tag and not within the li tag that my inner ul was attached to. If you wrap your inner ul in its own li tag you'll get an additional unneeded bullet. Show activity on this post. You need to put the inner ul inside an li element.


1 Answers

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> 
like image 190
Jonny Haynes Avatar answered Sep 19 '22 21:09

Jonny Haynes