What are the dangers of inserting <li>...</li>
into a page without enclosing the item(s) in a <ul>
block? For example:
<div style="border:solid 1px red;">
<li>Item</li>
<li>Another Item</li>
<li>Yet Another Item</li>
</div>
Validation is the least of my concerns, I'm wondering what this might break in browsers for the end user's ability to view the page as intended.
Unexpected rendering behaviors on different browsers ? SEO ?
As a web designer/developer you know you're way off when you start writing HTML that even Frontpage or Microsoft Word wouldn't generate.
Adhering to standards is a two-way street. If we want browser developers to create fast, reliable and consistent rendering engines we need to meet them half-way by creating consistent, clean and well-formed HTML.
Dangerous? It won't blow anything up. It may cause issues if the layout is in any way important to you.
You just won't know how the browser will render it.
This is echoing everybody else's answer, in part: with any markup, there's an empirical question of whether it works or not on the browsers that you are testing it on. You tested it on all your browsers, and your happy. That's cool and is a huge part of the work.
But beyond that, there's also the hypothetical question of how well it might work on browser-platform combinations that you haven't tested, either because:
For this set, which always becomes relevant sooner or later, you should follow standards -- when possible -- and use the enclosing UL or OL tags (in this case).
It's also worth mentioning that it makes the LI tags easier to track down if you are doing scripting, or if someone is doing scripting on your page (e.g., Greasemonkey).
I cant really imagine why you wouldnt want to put the
<ul>
or<ol>
tags in, they define the list. You then have control on how the list is displayed, not leaving it for the browser to decide, which is important. Missing them out is just writing invalid markup, yeah it will work in some browsers, but id definitely keep them in.It would be up to the browser's implementation to decide what to do with it. If you really want to do this, test it out in all the browsers you want to support before using it.
Also note that the browsers' behaviours might change in the future.