Home > Web Front-end > CSS Tutorial > Share five ways to set text color in CSS

Share five ways to set text color in CSS

yulia
Release: 2018-09-26 14:25:21
Original
3906 people have browsed it

When laying out the page, in order to make the page color less uniform, it is necessary to set different colors for the text. This article will tell you how to set different colors for the text and what methods are available to set the color of the text. Friends in need can refer to it.

The color of CSS Chinese text is set through the color attribute.

The following are several methods, all of which set the text to blue.

h3{color:blue;}

h3{color:#00f;}

h3{color:#0000ff;}

h3{color :rgb(0,0,255);}

h3{color:rgb(0%,0%,100%);}

When setting the color of a certain paragraph of text, you usually use < span> mark, mark the required parts separately, and then set the color attribute of the mark.

<span style="font-size:24px;"><html>
<head>
<title>文字颜色</title>
<style>
<!--
h2{color:rgb(0%,0%,80%);}
p{color:#333333;
font-size:13px;}
p span{color:blue;}
-->
</style>
</head>

<body>
<h2>冬至的由来</h2>
<p>
<span>冬至</span>过节源于汉代,盛于唐宋,相沿至今。《清嘉录》甚至有“<span>冬至</span>大如年”之说。这表明古人对<span>冬至</span>十分重视。人们认为<span>冬至</span>是阴阳二气的自然转化,是上天赐予的福气。汉朝以<span>冬至</span>为“冬节”,官府要举行祝贺仪式称为“贺冬”,例行放假。《后汉书》中有这样的记载:“<span>冬至</span>前后,卷子安身静体,百官绝事,不听政,择吉辰而后省事。”所以这天朝廷上下要放假休息,军队待命,边塞关闭,商旅停业,亲朋各以美食相赠,相互拜访,欢乐的度过一个“安身静体”的节日。
</p>
<p>
唐、宋时期,<span>冬至</span>是祭天祭祀祖的日子,皇帝在这天要到郊外举行祭天大典,百姓在这一天要向父母尊长祭拜,现在仍有一些地方在<span>冬至</span>这天过节庆贺。
</p>
</body>
</html>
</span>
Copy after login

In HTML pages, colors are uniformly in the RGB format, which is what people usually call the three primary color modes of red, green and blue.

Each color is composed of different proportions of these three colors, divided into 0~255 levels. When all three components are set to 255, it means white, or rgb (100%, 100% ,100%), or #FFFFFF both represent white.

#FFFFFF is a hexadecimal representation, where the first two digits are red, the middle two digits are green, and the last two digits are blue. FF is converted to decimal and is 255.

When the three components of RGB are all 0, it is displayed as black, that is, #000000 or rgb(0%,0%,0%) both represent black.

The above is the detailed content of Share five ways to set text 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