Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css bold first word

Tags:

How can I bold the first word of sentence using CSS selectors and is this a good/bad way to do this with respects to browser comparability?

code:

  <h2>this is a sentence</h2>

thx

like image 454
Adam Avatar asked Sep 16 '11 05:09

Adam


People also ask

How do I make the first text bold in CSS?

To bold text simply for decoration, use the CSS font-weight property instead of the HTML strong element. Let's say you want to bold a word in a paragraph — you'd wrap the word in <span> tags and use a CSS class selector to apply the font-weight property to the specific span element only.

How do I color the first word in CSS?

Solutions with CSS and HTML If you want to change the color of the first word of a text, you can use the CSS :before pseudo-element, which is used to add any element. Its value is defined with the content property. If it is not used, the content will not be generated and inserted.

How do I make one word bold in HTML?

To make text bold in HTML, use the <b>… </b> tag or <strong>… </strong> tag. Both the tags have the same functioning, but <strong> tag adds semantic strong importance to the text.


Video Answer


1 Answers

There is no ::first-word pseudo-element in CSS; you'll have to wrap the first word in an extra element and then select that.

like image 175
BoltClock Avatar answered Sep 29 '22 09:09

BoltClock