How to make font bold in css

下次还敢
Release: 2024-04-25 19:00:24
Original
745 people have browsed it

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>
Copy after login

CSS Code

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

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

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>
Copy after login

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!

Related labels:
css
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!