How to set font size and font color in css

WBOY
Release: 2021-11-12 09:25:05
Original
10801 people have browsed it

In CSS, you can use the "font-size" and color attributes to set the font size and font color. You only need to add "{font-size: font size value; color: color value;}" to the font element. Just style it.

How to set font size and font color in css

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

How to set font size and font color in css:

1. Use the font-size attribute to set the font size

Demo code:

.demo1{font-size: 20px;}
Copy after login

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style type="text/css">
    .demo1{font-size: 20px;}
    .demo2{font-size: 50px;}
    </style>
</head>
<body>
    <p class="demo1">文字大小1</p>
    <p class="demo2">文字大小2</p>
</body>
</html>
Copy after login

Output result:

How to set font size and font color in css

2. Use the color attribute to set the font color

Demo code:

.demo1{color: #FF0000;}
Copy after login

Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style type="text/css">
    .demo1{color: #FF0000;}
    .demo2{color: #0E931C;}
    </style>
</head>
<body>
    <p class="demo1">文字颜色1</p>
    <p class="demo2">文字颜色2</p>
</body>
</html>
Copy after login

Output result:

How to set font size and font color in css

For more programming related knowledge, please Visit: Programming Video! !

The above is the detailed content of How to set font size and font color in css. 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