Bold a part of a form label text?

#1

Hi there,

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

Thanks!

0 Likes

#2

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