Home > Web Front-end > HTML Tutorial > How to make font bold in html

How to make font bold in html

青灯夜游
Release: 2023-01-06 11:15:42
Original
95811 people have browsed it

htmlMethods to bold fonts: 1. Use the "<b>" tag, the syntax <b>text that needs to be bolded"; 2. Use the style attribute in the tag, Add the "font-weight:bold|bolder" style, with the value "bold" defining bold characters and "bolder" defining bolder characters.

How to make font bold in html

This tutorial Operating environment: windows7 system, CSS3&&HTML5 version, Dell G3 computer.

Method 1: Use <b> tag

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title> <b>加粗字体</title>
	</head>
	<body>
		<div>
			<p>这是一段测试文字,<b>这里使用b标签来加粗字体</b>
			</p>
		</div>
	</body>
</html>
Copy after login

Operating effect:

How to make font bold in html

We can already see from the picture that the second half of the text has a bold font, which can be compared with the first half of the text (the text is bold). Here we mainly use The <b> tag in html, the use of the <b> tag in html is very simple, just write the required information directly in the <b> tag Just make the text bold!

Method 2: Use the style attribute in the tag and add the "font-weight:bold|bolder" style

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

Rendering :

How to make font bold in html

Description:

The font-weight attribute can set the thickness of the text, which is generally used to set the bold font used in the text of the display element

Attribute values ​​related to the bold effect:

Value Description
bold Define 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.

Recommended tutorial: "html video tutorial"

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

Related labels:
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