To select one word from a sentence in bold type using HTML you need to use the tag <b>Word</b> or <strong>Word</strong> . But everyone says that you need to do the design completely in CSS. For fat content in CSS, font-weight: is responsible. I tried to enclose the word in <div></div> , but it transfers the text after the modified word to a new line. How can I solve the problem?

  • 2
    do not listen to all of them, this is nonsense. Use strong , it is for this and invented. - xaja
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

2 answers 2

Put it in the span tag:

 span.bold { font-weight: bold; } 
 Привет, <span class="bold">мир</span>! 

    Sometimes semantics is inseparable from design - in this case, just use <b> or <strong> .

    If the design is somehow related to semantics, then the fat content can be "hung" on any semantic tag. For example, on <abbr> if you need to write bold abbreviations. Or on <kbd> if you need to highlight a keyboard shortcut.

    The universal inline tag is <span> . But it is desirable to use it only with the specification in the form of a class:

     <span class="selected-word">foo</span> span.selected-word { font-weight: bold; } 

    Well, about <div> . This tag can also be used if you set it display: inline style. But I would not recommend doing so, because the semantics here will definitely break (div is a section in the text, and not a word).