Home > Web Front-end > HTML Tutorial > How to adjust font color in html

How to adjust font color in html

下次还敢
Release: 2024-04-11 08:43:56
Original
392 people have browsed it
<p>You can use CSS to adjust font color in HTML. There are two common methods: inline styles and external style sheets. Color value types include hexadecimal, RGB, RGBA, and color name. Commonly used color values ​​are black, white, red, green, blue and yellow.

<p>How to adjust font color in html

<p>HTML How to adjust the font color

<p>In HTML, you can use CSS (Cascading Style Sheets) to adjust the font color color. The following are two common methods:

<p>1. Use inline styles

<p>Inline styles are applied directly to HTML elements with the following syntax:

<code class="html"><p style="color: red;">文本</p></code>
Copy after login
<p>Among them, the "color" attribute defines the font color, and "red" is the color value.

<p>2. Using an external style sheet file

<p>The external style sheet file is a separate file that contains all CSS rules. To reference an external style sheet file in an HTML document, the syntax is as follows:

<code class="html"><link rel="stylesheet" href="style.css"></code>
Copy after login
<p>In an external style sheet file, use the following syntax to set the font color:

<code class="css">p {
  color: blue;
}</code>
Copy after login
<p>Where, the "p" selector matches all <p> element, the "color" attribute defines the font color, and "blue" is the color value.

<p>Color value types

<p>Color values ​​in CSS can have the following types:

  • Hex Hexadecimal value: For example, #FF0000 represents red
  • RGB value: For example, rgb(255, 0, 0) also represents red
  • RGBA value:Same as RGB, but with added transparency, for example, rgba(255, 0, 0, 0.5) represents translucent red
  • Color name: For example, "red" represents red , "white" means white
<p>Common color values

<p>The following are commonly used color values ​​in HTML:

  • Black: #000000
  • White: #FFFFFF
  • Red: #FF0000
  • Green :#008000
  • Blue:#0000FF
  • Yellow:#FFFF00

The above is the detailed content of How to adjust font color in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template