Anonymous block-block versus block-element
Can anonymous block-block be used instead of block-element? What are the pros and cons?
<div>
Some text
<p>More text</p>
</div>
against
<div>
<p>Some text</p>
<p>More text</p>
</div>
PS The question arose after reading this paragraph http://www.w3.org/TR/CSS2/visuren.html#anonymous-block-level .
source to share
You should use semantic markup, that is, use HTML tags that correctly describe your content. Look at the CSS specs themselves that say:
CSS gives so much authority to the "class" attribute that authors could develop their own "document language" based on elements with almost no representation (for example, DIVs and SPANs in HTML) and assigning style information through the "class". Authors should avoid this practice, as the structural elements of the document language often recognized and assumed values, and the classes defined by the author could not.
I talk about this more in this article: http://phrogz.net/CSS/HowToDevelopWithCSS.html#semanticmarkup
In your particular case, if you use CSS to accomplish something like this p:first-line { text-indent:2em }
, it won't apply to your "some text" unless you include the wrapper element. If you enable <p>
then all style that is applied to paragraphs will be displayed correctly.
(And you can use a more appropriate element than <div>
, for example <section>
, if applicable.)
source to share