Bold a part of a form label text?

Hi there,

I am wanting to bold a specific part of a form label. Is this possible?

Thanks!

According to the specs…
4.10.4 The label element

Phrasing content is allowed as a descendant of the label

Content model:
Phrasing content, but with no descendant labelable elements unless it is the element’s labeled control, and no descendant label elements.

That means you can nest a <span> tag in there, then style it to bold the portion of text you wish.

label span {
  font-weight:bold;
}

Take note of the Accessibility concerns mentioned at MDN.

Do not nest headings (h tags) or interactive content ( anchors or buttons) in the label.

5 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.