tags:

views:

1940

answers:

9

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?

+15  A: 

You're thinking of the CSS property font-weight:

p { font-weight: bold; }
mipadi
Well, hopefully he doesn't copy what you have exactly...would mess a few things up :)
Darryl Hein
It's a syntactically-correct example. The OP will have to decide just _how_ he wants it to be used.
mipadi
+3  A: 

Its in CSS you have to set font-weight: bold; as style

serioys sam
A: 

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 :)

Julian Aubourg
+1  A: 

you could also do <p style="font-weight:bold;">bold text here</p>

John Boker
inline styles are about to be deprecated in html 5 :P
lock
Are you sure? i thought only inline style tags were to be deprecated, ie. (big,s,strike,tt,u)
John Boker
Even if they're not deprecated, they're almost always a bad idea. You might as well go back to using <font> tags.
tgecho
+4  A: 

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.

alex
Yes, there is <strong> now.
Garrett
It *has* been deprecated all right. ;-)
Cerebrus
Thanks guys for clearing that up.
alex
<b> is NOT deprecated. It is still supported in HTML 4.01, XHTML 1, XHTML 1.1, and even the upcoming HTML 5. Its deprecation is a myth. Whether it *should* be deprecated is another matter. It isn't. See also http://www.w3.org/TR/html401/index/elements.html
thomasrutter
Small technicality: a class name cannot be called 'semantic' because it is not a controlled vocabulary: there is no standard anywhere that defines what "important-message" means across apps. Naming your classes by their function is still a good idea because it promotes readability and best practice.
thomasrutter
@thomasrutter... That's why I said *think*. A name doesn't have to be semantic only to computers; people read html too.
alex
+11  A: 

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.

Darryl Hein
high five, i was just writin' this. <b> has been deprecated for years
nailitdown
<b> is NOT deprecated in any current HTML or XHTML standard, nor is it deprecated even in the upcoming HTML 5. <b> and <strong> have distinct meanings; <b> means "bold styled text". <strong> means "stronger emphasis", but does not dictate a text style; browsers default to bold.
thomasrutter
The widespread use of <b> has dwindled, but the actual element hasn't been deprecated according to the W3C specs.
alex
My bad...don't trust others :)
Darryl Hein
The <b> is effectively deprecated in HTML5...and replaced with another <b> tag that has a somewhat different meaning. It's a weird choice, but that's basically what they've done. At any rate, it shouldn't be used to style text as bold.
Chuck
@Chuck: what does the new b element mean ?
alex
Hmm, yeah, chuck?
Darryl Hein
Per the draft spec: It indicates "a span of text to be stylistically offset from the normal prose without conveying any extra importance" — like keywords that might be bolded in marketing material. Basically, it's an attempt to give the <b> tag a *meaning* that doesn't conflict with current use.
Chuck
A: 

On a sidenote the below code will also make it bold.

<strong> text here </strong>
Binoj Antony
... in most browsers ... but only as a side effect of describing the text as having stronger emphasis.
David Dorward
A: 

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.

Matthew James Taylor
Don't use things because they are "more semantic" - use them because they have the semantics that apply to what you are writing. We don't know what the semantics of the text the OP has are.
David Dorward
+1  A: 

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.