Home > Article > Web Front-end > How to set font size and font color in css
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.
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;}
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>
Output result:
2. Use the color attribute to set the font color
Demo code:
.demo1{color: #FF0000;}
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>
Output result:
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!