Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we add <ul> inside <a> tag?

when im writing html code inside of anchor tag, my dreamweaver editor showing bug in anchor tag. Shouldnt use inside tag? Is there any rules writing/using tags ?

I am using Html 5. This is my code. http://jsfiddle.net/CfPnj/

like image 960
Pavan Kumar Avatar asked Jun 08 '12 09:06

Pavan Kumar


People also ask

How do you put a UL in a tag?

Use the <ul> tag together with the <li> tag to create unordered lists.

Can I put UL inside p tag?

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

Can we have UL inside Li?

The children (direct descendants) of a ul element must all be li elements. This is a purely syntactic requirement. The way to fix the error depends on semantics, however. If the inner lists correspond to subtopics of the topic of the preceding li , then you should wrap the inner list inside that li , e.g.

What 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.


1 Answers

In HTML5, you can put block elements insize <a> elements. See http://dev.w3.org/html5/markup/a.html#a-changes
This is new in HTML5. In any other version of HTML, it's illegal.

Update (added later, when I understood HTML5 better)

This is because <a>'s content model was changed from inline to transparent. In other words, what you can put inside an <a> is now the same as what you can put in <a>'s parent. The actual answer to the question here is, "it depends".
For instance,

<div><a><ul><li></ul></a></div>

is perfectly valid HTML5, while

<span><a><ul><li></ul></a></span>

is not (because span is an inline element).
Hope this helps!

like image 192
Mr Lister Avatar answered Nov 10 '22 00:11

Mr Lister