tags:

views:

827

answers:

8

I'm trying to make some text bold using HTML, but it doesn't work.

Here's what I'm trying:

Some <bold>text</bold> that I want bolded.

Could someone tell me what I'm doing wrong?

A: 

Use the <b> tag.

Geo
A: 

It’s just <b> instead of <bold>:

Some <b>text</b> that I want bolded.

Note that <b> just changes the appearance of the text. If you want to render it bold because you want to express a strong emphasis, you should better use the <strong> element.

Gumbo
+2  A: 

The Markup Way:

<strong>I'm Bold!</strong> and <b>I'm Bold Too!</b>

The Styling Way:

.bold {
  font-weight:bold;
}

<span class="bold">I'm Bold!</span>

From: http://www.december.com/html/x1/

<b>

This element encloses text which should be rendered by the browser as boldface. Because the meaning of the B element defines the appearance of the content it encloses, this element is considered a "physical" markup element. As such, it doesn't convey the meaning of a semantic markup element such as strong.

<strong>

Description This element brackets text which should be strongly emphasized. Stronger than the em element.

Jonathan Sampson
`strong` is not the same as `b`.
Gumbo
Never said that they were.
Jonathan Sampson
+11  A: 

use <strong> or <b> tag

also, you can try with css <span style="font-weight:bold">text</span>

Andrija
+11  A: 

HTML doesn't have a <bold> tag, instead you would have to use <b>. Note however, that using <b> is discouraged in favor of CSS for a while now. You would be better off using CSS to achieve that.

The <strong> tag is a semantic element for strong emphasis which defaults to bold.

Joey
-1 `b` is not deprecated.
Gumbo
+1 b is HTML 4, you should not it ever strong/css is the way to go
googletorp
I stand corrected, thanks.
Joey
<b> has never been deprecated. Recommended against in favor of <em>, <strong>, <h1..6>, etc., yes; deprecated, no.
Noah Medling
Why should using `<b>` be discouraged in favor of CSS? That’s like saying using `<h`*`n`*`>` is discouraged in favor of CSS. It’s in the standard so use it.
Gumbo
Gumbo: From http://www.w3.org/TR/html4/present/graphics.html#h-15.2.1 – "The following HTML elements specify font information. Although they are not all deprecated, their use is discouraged in favor of style sheets."
Joey
Actually those elements are making a comeback in HTML 5 as "phrase elements" - for example <small> symbolises small print, while <b> is to be used for book titles, I think.
DisgruntledGoat
+1  A: 

I think the real answer is http://www.w3schools.com/HTML/default.asp.

John Saunders
w3schools is rarely the real answer
Gareth
Exactly. If you don't know how to make bold text in HTML, and don't how to find out, you need to start with lesson 1.
myplacedk
@Gareth: what do you consider wrong with w3schools, and what do you consider the correct answer to someone who doesn't know day-one HTML? Ok, maybe day-two if they're short days.
John Saunders
A: 

Another option is to do it via CSS ...

E.g. 1

<span style="font-weight: bold;">Hello stackoverflow!</span>

E.g. 2

<style type="text/css">
    #text
    {
        font-weight: bold;
    }
</style>

<div id="text">
    Hello again!
</div>
Chalkey
-1 for giving a correct solution?
Chalkey
+1  A: 

Could someone tell me what I'm doing wrong?"

"bold" has never been an HTML element ("b" is the closest match).

HTML should contain structured content; publisher CSS should suggest styles for that content. That way user agents can expose the structured content with useful styling and navigational controls to users who can't see your suggested bold styling (e.g. users of search engines, totally blind users using screen readers, poorly sighted users using their own colors and fonts, geeky users using text browsers, users of voice-controlled, speaking browsers like Opera for Windows). Thus the right way to make text bold depends on why you want to style it bold. For example:

  • Want to distinguish headings from other text? Use heading elements ("h1" to "h6") and suggest a bold style for them within your CSS ("h1, h2, h3, h4, h5, h6 {font-weight: bold;}".

  • Want to embolden labels for form fields? Use a "label" element, programmatically associate it with the the relevant "select", "input" or "textarea" element by giving it a "for" attribute matching an "id" attribute on the target, and suggest a bold style for it within your CSS ("label {font-weight: bold;"}).

  • Want to embolden a heading for a group of related fields in a form, such as a group of radio choices? Surround them with a "fieldset" element, give it a "legend" element, and suggest a bold style for it within your CSS ("legend {font-weight: bold;}").

  • Want to distinguish a table caption from the table it captions? Use a "caption" element and suggest a bold style for it within your CSS ("caption {font-weight: bold;}").

  • Want to distinguish table headings from table data cells? Use a "th" element and suggest a bold style for it within your CSS ("th {font-weight: bold;}").

  • Want to distinguish the title of a referenced film or album from surrounding text? Use a "cite" element with a class ("cite class="movie-title"), and suggest a bold style for it within your CSS (".movie-title {font-weight: bold;}").

  • Want to distinguish a defined keyword from the surrounding text defining or explaining it? Use a "dfn" element and suggest a bold style for it within your CSS ("dfn {font-weight: bold;}").

  • Want to distinguish some computer code from surrounding text? Use a "code" element and suggest a bold style for it within your CSS ("code {font-weight: bold;}").

  • Want to distinguish a variable name from surrounding text? Use a "var" element and suggest a bold style for it within your CSS ("var {font-weight: bold;}").

  • Want to indicate that some text has been added as an update? Use an "ins" element and suggest a bold style for it within your CSS ("ins {font-weight: bold;}").

  • Want to lightly stress some text ("I love kittens!")? Use an "em" element and suggest a bold style for it within your CSS (e.g. "em {font-weight: bold;}").

  • Want to heavily stress some text, perhaps for a warning ("Beware the dog!")? Use a "strong" element and suggest a bold style for it within your CSS (e.g. "strong {font-weight: bold;}").

… You get the idea (hopefully).

Can't find an HTML element with the right semantics to express /why/ you want to make this particular text bold? Wrap it in a generic "span" element, give it a meaningful class name that expresses your rationale for distinguishing that text ("<span class="lede">Let me begin this news article with a sentence that summarizes it.</span>), and suggest a bold style for it within your CSS (".lede {font-weight: bold;"}. Before making up your own class names, you might want to check if there's a microformat (microformats.org) or common convention for what you want to express.

Benjamin Hawkes-Lewis