views:

120

answers:

8

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?

A: 

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.

thephpdeveloper
or you could just do <span>Some Text</span> and let the stylesheet worry about styling it. You know, the way they're meant to do.
jalf
or better still, use a semantically meaningful tag, like, say, <em>SomeText</em>
jalf
A: 

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.

Babak Ghahremanpour
A: 

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.

Gerardo
A: 

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.

pixelbeat
+6  A: 

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.

dnagirl
A: 

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.

Kevin
+1  A: 

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'> ...?

Joe
+2  A: 

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

Phil
the 'new/better definitions' now only borders on deprecated for 'b'. From the HTML5 specs: The b element should be used as a last resort when no other element is more appropriate. In particular, headings should use the h1 to h6 elements, stress emphasis should use the em element, importance should be denoted with the strong element, and text marked or highlighted should use the mark element.
Joe
+1, I use `<small>` all the time for "small print", any time I want to put a small aside. SO could even use it on the front page for "votes" and "answers" under the numbers.
DisgruntledGoat