In web design, the choice of font style and layout skills are very important. If you want to emphasize a certain paragraph or word, you can use bold font to highlight it. So, how to make bold fonts in CSS? This article will introduce you to several methods in detail.
The font-weight attribute of CSS is used to control the boldness of the font. Generally, the default weight of fonts is 400. If you want to make the font bolder, you can set the value of the font-weight attribute to 700 or higher. For example:
font-weight:bold;
The above code will make the selected text bold.
The strong tag is a tag built into HTML and is used to indicate emphasized text. By default, the strong tag renders text in bold font. For example:
这是一段加粗的文字
The b tag is also a tag built into HTML and is used to indicate the importance of text, but it is not necessarily used to emphasize the text . By default, the b tag also renders text in bold font. For example:
这是一段加粗的文字
If you want to make the font of a certain area bold, you can set a CSS class named "bold" or whatever you want. Like the name. For example:
.bold{ font-weight:bold; }
Then, wrap the text that needs to be bolded in the tag of this class in HTML. For example:
这是一段需要加粗的文字
Summary:
The above are several common CSS bold font methods. If there are no special requirements, it is recommended to use the CSS font-weight property to control the boldness of the font. In addition, it should be noted that bold fonts should not be used excessively, so as not to affect the aesthetics and readability of the article.
The above is the detailed content of How to bold fonts in css. For more information, please follow other related articles on the PHP Chinese website!