can we give <div> within <li>

一曲冷凌霜 提交于 2020-01-21 06:51:48

问题


can we give div tag within un order list tag.............. it will be in this format

<li><div>blablabla</div></li>

Is it Possible


回答1:


There are a lot of people that say a division inside a list item is incorrect, but according to the W3C validator it is perfectly fine. You'll never catch me putting divisions inside a list item though. Lists are too malformed to be putting additional block-level elements inside them.




回答2:


Syntactically, if you are unsure about the nesting of elements, there are free tools that will tell you what, if anything, is wrong. For example:

http://validator.w3.org/

Whether or not it is semantically correct is another story. You might be suffering of divitis.




回答3:


I assume you're making a horizontal nav bar. If my assumption is correct, you don't need a <div> inside <li>. You can use display:inline; to get <li> to behave some what like <div>.




回答4:


yes, but you need the < ol > tag also wrapping all the < li > tags that can have whatever you want inside them



来源:https://stackoverflow.com/questions/3011934/can-we-give-div-within-li

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!