Originally Posted by LearningCoder
Thanks for your reply. I have given my list items a style of
display: inline so that they display horizontally. I have seen many examples of this when looking at CSS Menu's which you can download from sites.
This is invalid in terms of HTML standards. First of all, a simple list consists of two elements,
to denote that something is a list (unordered or ordered), and
to mark up every distinct item in this list. Therefore it is a requirement
that list items must be direct children of the list element. There canít be anything else as direct children of
<!-- correct -->
<!-- wrong -->
the list items you can put whatever elements you like but you canít put anything you like directly inside
. This is a fact defined by the Word Wide Web Consortium as HTML standards specification. If you have seen it otherwise on websites they are wrong (and Iím wondering where you have seen that).
Basic rule of thumb: Inline elements can go into block-level elements but not vice versa. And it doesnít matter if you style
block-level elements to look and behave like inline elements, intrinsically, they are block-level elements and an HTML validator will throw an error if they are found inside an inline element.