MyBB Community Forums

Full Version: please do away with presentation junk in the html!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7
(2012-04-17, 10:20 PM)Charlie Hadden Wrote: [ -> ]To sum this up perfectly: <strong> and <em> should be used, <b> and <i> should not.

/thread

Purely presentational tags (such as <b> and <i>) should not be used in new code. HOWEVER, do not blindly use <strong> and <em> just because of the way they format the text. If you want text with a particular presentation (be it font style, font weight, or font color) but without added semantics use CSS.

Oh, and for the love of all that's good, use good descriptive class names in your CSS. A class should be named "error" instead of "red" for example because you may decide to change the presentation, and a "red" class which produces purple text is just wrong.
(2012-04-20, 05:07 AM)laie_techie Wrote: [ -> ]
(2012-04-17, 10:20 PM)Charlie Hadden Wrote: [ -> ]To sum this up perfectly: <strong> and <em> should be used, <b> and <i> should not.

/thread

Purely presentational tags (such as <b> and <i>) should not be used in new code. HOWEVER, do not blindly use <strong> and <em> just because of the way they format the text. If you want text with a particular presentation (be it font style, font weight, or font color) but without added semantics use CSS.

Oh, and for the love of all that's good, use good descriptive class names in your CSS. A class should be named "error" instead of "red" for example because you may decide to change the presentation, and a "red" class which produces purple text is just wrong.

Absolutely. That post you quoted was intended to go alongside my last post, however. Having said that ,most of the time if the only styling you want is to make it bold or italic, strong/em should be used, as you will usually be wanting it to be highlighted when viewed in other ways too. I agree with your point though, i'm just saying "most' of the time.
It's too bad that something that used to be simple (<b>) is now <span style="font-weight: bold;">

That does not seem like advancement to me.
What are you talking about? I don't recall anyone saying <b> was no longer usable. It is perfectly acceptable. In fact, it is in the HTML5 specification and it should be used when you need presentationally bold text with no semantic value. The span method is also acceptable, there's just no real advantage.

The only case you need to worry about is when you want to give strong importance to something but do not want it to look bold to users. In that case you should simply style it with CSS to make it look like normal text. However this is a rather rare scenario. Most people want important text to look bold, which is why browsers apply default styling to <strong>. If you do as well, then use <strong> for semantic value and <b> for presentation. That's it!
Sorry, I was going by W3C's recommendation that <b> was deprecated.
(2012-04-20, 05:01 PM)Fábio Maia Wrote: [ -> ]What are you talking about? I don't recall anyone saying <b> was no longer usable. It is perfectly acceptable. In fact, it is in the HTML5 specification and it should be used when you need presentationally bold text with no semantic value. The span method is also acceptable, there's just no real advantage.

If you talk about HTML5 (which is a draft standard):

Quote:Changes in HTML5

Although previous versions of HTML defined the b element only in presentational terms, the element has now been given the specific semantic purpose of representing text “offset from its surrounding content without conveying any extra emphasis or importance, and for which the conventional typographic presentation is bold text”.

It has a semantic value but it is different from the semantic value of the <strong> tag.
Sounds rather useless as a semantic tag, but it is indeed true. Thanks for pointing it out. Smile
Bah, arguing about semantics will never stop I guess Smile

I've done a few big and small projects and I concluded that sometimes semantics aren't the holy grail. Re-usability in your code is.

<span style="color:red">Warning!, do not eat someone else's cat!</span>

Isn't semantically correct. It's presentation-code in markup, which is a bad thing.
But what's a lot worse is that this code is not reusable.

<span class="red">Attention, Frogs are not toys!</span>

That is reusable, but semantically incorrect. How about:

<span class="warning">No feeding the kiwi's!</span>

That's more like it, but wait there's a problem.. What if we've got like 5 types of these warnings in different colors?

<span class="warning red">Do not set this on fire</span>
<span class="warning yellow">No making love in the forest</span>
<span class="warning orange">You passed the speed of light</span>
....

But wait didn't we just said that adding classnames like 'red' are semantically incorrect?
Would this be the way to go?:

<span class="warning severe">You got run over by a truck</span>
<span class="warning medium">You're out of icecream</span>
<span class="warning low">Your girlfriend cheated on you<strong>again</strong></span>

I'm not sure there's anything gained here really, in fact I think this abstraction is a bad thing. At some point you must realize that you are ultimately doing presentational stuff.
As long as you write code that is (re)usable the semantics take a backseat.
I'm not saying semantics are irrelevant, but it's also not the most important thing in the world.

<strong>I'm a big text, and proud to be so!</strong>
You can override it's style just fine even without a class in your stylesheet.
I use inline styling for presentation elements all the time ... I only bother to make classes if it's something that's going to be used quite often. It is just used once, it seems weird to make a class for it.
(2012-04-25, 05:52 PM)Uncontrol Wrote: [ -> ]It is just used once, it seems weird to make a class for it.

Precisely.

As long as we're able to style everything easily and consistently, we'll be fine.
Pages: 1 2 3 4 5 6 7