HTML text setting color
In HTML, we can make the page look more colorful by setting the text color. Text color settings can be applied to different elements such as text paragraphs, headings, links, etc. In this article, we will introduce how to set text color in HTML and use CSS to control text color more conveniently.
In HTML, we can use color names or hexadecimal color values to define text colors. Here are some commonly used HTML color names:
We can apply color in the following ways:
<p style="color:red;">这是红色的文本。</p> <p style="color:green;">这是绿色的文本。</p> <p style="color:blue;">这是蓝色的文本。</p> <p style="color:black;">这是黑色的文本。</p> <p style="color:white; background-color:black;">这是白色的文本。</p>
In the above example, we used the style attribute to set the color. By adding the color attribute to the style attribute, we can set the color of the text.
In addition to using color names, we can also use hexadecimal color values to define text colors. Here are some examples:
<p style="color:#ff0000;">这是红色的文本。</p> <p style="color:#00ff00;">这是绿色的文本。</p> <p style="color:#0000ff;">这是蓝色的文本。</p> <p style="color:#000000;">这是黑色的文本。</p> <p style="color:#ffffff; background-color:#000000;">这是白色的文本。</p>
In the above example, we used the # character followed by the color code to set the color. The color code consists of 6 hexadecimal numbers, which respectively represent the brightness values of red, green and blue colors. For example, #ff0000 represents red, and ff represents the maximum brightness value of red.
In the above example, we used the style attribute to set the text color. However, for large websites or projects, we need to apply the same style on multiple pages and elements. In this case, we can use CSS to control the appearance and style of the page.
Let's first look at how to use an internal style sheet to set text color. An internal style sheet is a style sheet written in the