Okay, so I know that in HTML you can use the <b>
tag, but isn't there a "weight=bold" attribute that I can use in the <p>
tag?
Or is that in CSS, or Javascript?
Okay, so I know that in HTML you can use the <b>
tag, but isn't there a "weight=bold" attribute that I can use in the <p>
tag?
Or is that in CSS, or Javascript?
You're thinking of the CSS property font-weight
:
p { font-weight: bold; }
It's all historical and dates from a time where dinosaurs walked the earth and CSS didn't exist.
More seriously, forget about the b tag and use font-weight:bold in a CSS rule :)
you could also do <p style="font-weight:bold;">bold text here</p>
If the text's meaning is semantically 'strong', use the <strong>
element. If not, use a semantic named class and reference it in your CSS.
<span class="important-message">I'm important!</span>
.important-message {
font-weight: bold;
}
Some people still use the <b>
element as a presentational hook, but it hasn't been deprecated, though most people favour the <strong>
element nowadays. Just make sure they are used correctly.
Also consider the <strong>
tag. It's much better for screen readers and therefore better for accessibility. I'm also thinking that spiders may use <strong>
tags to determine important content.
Although, if you are bolding the entire paragraph, you may not want to use it--I'm not sure what the affect on screen readers would be.
On a sidenote the below code will also make it bold.
<strong> text here </strong>
Use the <strong>
tag because it's more semantic. <b>
has been depreciated so it's best not to use it. Also bold text is given more Search Engine Optimisation (SEO) weight so it's always best to use a real <strong>
rather than making a <p>
or <span>
bold using CSS.
The <b> tag is alive and well. <b> is not deprecated, but its use has been clarified and limited. <b> has no semantic meaning, nor does it convey vocal emphasis such as might be spoken by a screen reader. <b> does, however, convey printed empasis, as does the <i> tag. Both have a specific place in typograpghy, but not in spoken communication, mon freres.
To quote from http://www.whatwg.org/
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.