Alternative to the HTML Bold tag

后端 未结 21 1817
野性不改
野性不改 2020-12-23 15:35

Okay, so I know that in HTML you can use the tag, but isn\'t there a \"weight=bold\" attribute that I can use in the

相关标签:
21条回答
  • 2020-12-23 16:36

    It's all historical and dates from a time where dinosaurs walked the earth and CSS didn't exist.

    More seriously, forget about the <b/> tag and use font-weight:bold in a CSS rule :)

    0 讨论(0)
  • 2020-12-23 16:38

    A very old thread, I know. - but for completeness:

    I use <span class="bold">my text</span>    

    as I upload the four font styles: normal; bold; italic and bold italic into my web-site via css.

    I feel the resulting output is better than simply modifying a font and is closer to the designers intention of how the boldened font should look.

    The same applies for italic and bolditalic of course, which gives me additional flexibility.

    0 讨论(0)
  • 2020-12-23 16:39

    Also consider the <strong> tag. It's much better for screen readers and therefore better for accessibility. Search engines also use <strong> tags to determine important content similar to how they use header tags <h1>, <h2>, etc (although <b> will also have similar meaning to search engines). If you want to stress importance of text, use <strong>. If you don't want to stress importance, use the <b> tag or use the font-weight:bold; style on the element or in the CSS.

    Although, if you are bolding the entire paragraph, it's probably better to use the CSS option. This will reduce the affect on screen readers and it probably doesn't make sense to have an entire paragraph emphasized. But on the other hand, I've seen bold used to emphasize an entire paragraph before for good reason. In which case, font-weight:bold; is what you want to use, likely in a class/style.

    In the end, <strong>, <b> or font-weight:bold; will all work and accomplish something similar visually (probably exactly the same), but they have slightly different meanings. Also, make sure that if what you're bolding is a header, use the header tags: <h1>, <h2>, etc.

    0 讨论(0)
提交回复
热议问题