Why HTML 5 still have support for Presentational elements?
See list here:
http://www.w3schools.com/html5/html5_reference.asp
like <b>
, <i>
, <br>
, <hr>
, <small>
?
Is it means no cons to use these? But wha开发者_运维技巧t about content and presentation seperation?
Two reasons come to mind:
Because some people (not me, here is a primer about this opinion and here are the WHATWG FAQ about this) don't think of them as presentational. They argue, that
<b>
has semantics of its own, for example, where<strong>
is not right and the text should be bold anyways (IMHO therefore we have<span>
)Because HTML5 has a pragmatic and backwards compatible approach: What worked in HTML4 should work too in HTML5. They argue, that this is why XHTML2 died.
First have a look what WHATWG says about it (this is also mentioned in the answer to the related question cited above).
It is said (as I thought, too) that <strong> and <em> provide an emphasis when using a screen reader, but according to this article by Harry Roberts, it turns out that in practice screen readers don't accentuate text marked this way.
And last, read the spec about <b> (it's already mentioned in the FAQ in the first link, above):
The b element represents a span of text to be stylistically offset from the normal prose without conveying any extra importance, such as key words in a document abstract, product names in a review, or other spans of text whose typical typographic presentation is boldened.
and <i>:
The i element represents a span of text in an alternate voice or mood, or otherwise offset from the normal prose, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, a thought, a ship name, or some other prose whose typical typographic presentation is italicized.
Likewise, have a look at <small>, <hr> and <br> (there are examples there, too.)
They have also redefined the meaning and semantics of several of these elements. They realized the need for an element that does something like <b>
and there was already an element, so they kept it, and preserved backwards compatibility, instead of introducing something new.
精彩评论