The tt, i, b, big, and small tags are not deprecated, but it开发者_开发知识库 is possible to achieve richer effect with CSS. What is the merit of using these?
Well, it might be said that a styled <div>
or <span>
could do pretty much anything that other html tags can, so why have more than these tags? The answer is that the tags are not principally for styling. They are principally for identifying types of information. So, <em>
is not used for putting on italics; it's used for indicating that the content inside should be emphasized. What emphasis is depends on the content reader.
Although yes, it's shorter and there's ease of use, the issue at hand is semantic markup -- basically, there's no question about what <strong>
and <em>
are supposed to mean to the user. This is especially important for cases where color and font-weight are meaningless (eg, to a blind person who's using a text-to-speach system).
If you're working for a US government agency (any government in the US, not just feds), you're bound by the American with Disabilities Act. Feds are specifically bound by Section 508 ... but in practice, it's also good to follow the Web Content Accessibility Guidelines. Companies would be wise to also follow the guidelines to reduce the possibility of a lawsuit and then having to redesign the side to correctly handle these issues.
ps. The one element that you didn't mention that's always bugged me is specifically <th>
... why the hell do people like using <td><b> ... </b></td>
or <td class='header'> ...
?
small, b and i all have new/better definitions in the HTML5 spec and will have greater meaning in the future.
Other people like to use b or i elements to denote purely visual markup, for example in the Nifty corners technique for adding rounded corners to boxes
Compare the following:
<span style="font-weight:bold">Some Text</span>
and
<style type="text/css"><!-- .b{font-weight:bold;} --></style>
<span class="b">Some Text</span>
and
<b>Some Text</b>
Definitely <b>
and </b>
is the shortest. Also, those tags were quite heavily used even today where web standards has grown and matured a lot.
Perhaps it is because of semantics. It makes more sense for someone (robot, user) who reads the code to have <b>Some important text</b>
(really deprecated for: <strong>Some important text</strong>
) than <span style='font-weight:bold'>Some important text</span>
Span could contain anything, but, generally, strong contains something to be noticed.
The only "merit" I can think of is that they are support by all the major browsers and they are simple to us. For example, if all you want to do is italicize some piece of text, then just use i. It's much more simple than writing the equivalent in CSS and you'll know that it will work as expected.
The biggest merit of using these, is that it allows the browsing item (web browser etc.) to decide how the text in question is rendered. These were created to account for the fact that not all browsers might be able to display something in bold (anyone remember lynx?). Most of the time this isn't a problem anymore technology has moved a lot faster than the current standards, but it certainly was in the past. You figure that a phone with a color screen was a rarity 8 years ago, where it is commonplace now.
You shouldn't use these as they specify how to display rather than specifying the type. I.E. they couple the representation with the content which is bad for maintainability. So instead of <b>
use <strong>
. Then one can style <strong>
in one place if required.
精彩评论