Home > Web Front-end > CSS Tutorial > Set keyword font size using CSS

Set keyword font size using CSS

王林
Release: 2023-09-13 14:13:01
forward
776 people have browsed it

CSS font-size property can be set using absolute and relative keywords. This will scale the text as needed.

Syntax

The syntax of CSS font-size attribute is as follows-

Selector {
   font-size: /*value*/
}
Copy after login

The following table lists the standard keywords used in CSS-

##12345##large6x-large 7xx-large8Smaller9BiggerThe following example illustrates how to set the CSS font-size property using keywords.
Sr.NoValue &Description

Set the font size to medium. This is the default

xx-small

#set sets the font size to xx-small size

x-small< /p> Set font size to special Small

Small< /strong>

Set the font size to a smaller size

Set font size to large

Set font size to extra large

Set font size to xx-large size

Set the font size to be smaller than the parent element

Set the font size to a larger size than the parent element

Example

Live Demonstration

<!DOCTYPE html>
<html>
<head>
<style>
h1{
   font-size: larger;
}
#demo {
   font-size: medium;
   text-align: center;
   background-color: floralwhite;
}
p {
   font-size: xx-large;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<p id="demo">This is demo text.</p>
<p>This is another demo text.</p>
</body>
</html>
Copy after login

Output

This gives the following output-

使用 CSS 设置关键字的字体大小Example

Live Demonstration

<!DOCTYPE html>
<html>
<head>
<style>
div {
   margin: auto;
   padding: 5px;
   width: 30%;
   border: 1px solid;
   border-radius: 29%;
   text-align: center;
   font-size: xx-small;
}
p {
   font-size: xx-large;
}
</style>
</head>
<body>
<div>
<div>One</div>
<p>Two</p>
</div>
</body>
</html>
Copy after login

Output

This gives the following output-

The above is the detailed content of Set keyword font size using CSS. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
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