Home  >  Article  >  Web Front-end  >  How to make font bold in css

How to make font bold in css

下次还敢
下次还敢Original
2024-04-25 19:00:24830browse

You can use the font-weight attribute to bold a font in CSS. The default value is normal, and the bold value is bold. It also supports lighter (lighter), heavier (bolder), and 100-900 values ​​​​(400 is normal ).

How to make font bold in css

Bold fonts in CSS

Bold fonts in CSS is very simple, you can usefont-weight attribute.

HTML Code

<code class="html"><p>这是普通文本</p>
<p><strong>这是加粗文本</strong></p></code>

CSS Code

<code class="css">p {
  font-weight: normal;
}

strong {
  font-weight: bold;
}</code>

In this example, normal is the font The default weight of , while bold is the bold weight.

In addition to normal and bold, the font-weight property also supports the following values:

  • lighter: lighter than the current font weight
  • bolder: heavier than the current font weight
  • 100: the lightest Font weight
  • 200 - 900: Between light and heavy font weights (where 400 is the normal weight)

Example

To make text bold to medium weight, you can use the following CSS:

<code class="css">p {
  font-weight: 600;
}</code>

Browser support

# The ##font-weight attribute is well supported by all modern browsers.

The above is the detailed content of How to make font bold in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn