HTML Font Size
To set the font size in HTML, you can use the CSS font-size
property. Here’s an example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Font Size Example</title>
<style>
.small-text {
font-size: 12px;
}
.medium-text {
font-size: 16px;
}
.large-text {
font-size: 20px;
}
</style>
</head>
<body>
<p class="small-text">This is a small text</p>
<p class="medium-text">This is a medium text</p>
<p class="large-text">This is a large text</p>
</body>
</html>
In the above example, the CSS font-size
property is used to set the font size for different elements. Inside the <style>
tag, three classes are defined: .small-text
, .medium-text
, and .large-text
, each with a different font size value.
The <p>
paragraph elements have these classes applied, determining their respective font sizes. The .small-text
class sets the font size to 12 pixels, the .medium-text
class sets it to 16 pixels, and the .large-text
class sets it to 20 pixels.
You can customize the font size values by specifying different CSS length units, such as pixels (px
), ems (em
), or percentages (%
). You can also use other CSS length values or relative font size keywords such as small
, medium
, or large
.
Feel free to adjust the classes, elements, and font size values to suit your needs.