Home >Web Front-end >CSS Tutorial >How to make text bold in css

How to make text bold in css

青灯夜游
青灯夜游Original
2021-04-20 17:34:0747810browse

You can use the font-weight attribute in css to set text boldness. You only need to add the "font-weight:bold|bolder" style to the element. The value "bold" defines bold characters and "bolder" defines Thicker characters; you can also set the value to 700, 800 or 900 to make it bold.

How to make text bold in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

In CSS, you can use the font-weight attribute to set the text bold effect.

The font-weight attribute can set the thickness of the text. It is generally used to set the font boldness used in the text of the display element.

Attribute values ​​related to the bolding effect:

Value Description
bold Defines bold characters.
bolder Define bolder characters.
  • 100
  • 200
  • 300
  • 400
  • 500
  • 600
  • 700
  • 800
  • 900
Define characters from thin to thick. 400 is equivalent to normal, and 700 is equivalent to bold.

Example:

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>css 文字加粗</title>
		<style>
			p.normal {
				font-weight: normal;
			}
			p.bold {
				font-weight: bold;
			}
			
			p.bolder {
				font-weight: bolder;
			}
			
			p.thicker {
				font-weight: 900;
			}
		</style>
	</head>

	<body>
		<p class="normal">测试文本!</p>
		<p class="bold">测试文本!</p>
		<p class="bolder">测试文本!</p>
		<p class="thicker">测试文本!</p>
	</body>

</html>

Rendering:

How to make text bold in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to make text 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