"; 2. Write the style of "color:color" in the style tag; 3. Use the color attribute of the font tag Settings, syntax ""."/>
"; 2. Write the style of "color:color" in the style tag; 3. Use the color attribute of the font tag Settings, syntax "".">
Home >
Article > Web Front-end > How to change font color in html Method: 1. Use the style attribute in the html tag, with the syntax " The operating environment of this tutorial: Windows7 system, CSS3&&HTML5 version, Dell G3 computer. HTML is mainly used to write page layouts. In the process, it is often necessary to set the color of certain fonts on the page. There are usually three common ways to customize settings: 1. Set via external CSS styles. You can add style to the head tag, and add class="the name defined in the above style, such as blue" to other tags in the body, such as h1, p, div, etc., to start tags. The code is implemented as follows: #2. Set through internal CSS styles. In other tags in the body, such as h1, p, div and other start tags, just add style="color:white;font-size:25px;". The code is implemented as follows: 3. Set through the font tag. In other tag content in the body, add the font tag to set the font color and size, such as color="yellow" size="5". It should be noted that the maximum value of size is 7, and the font color and size are assigned using the equal sign. The first two CSS styles are assigned using English colons. The code is implemented as follows: Extended information There are three common units for defining font size on HTML web pages, namely: px, em, and pt. 1. Px is the abbreviation of pixel, which is a unit based on pixels. During the process of browsing the web, the text, pictures, etc. on the screen will change with the resolution of the screen. A picture with a width of 100px will At 800×600 resolution, it occupies 1/8 of the screen width, but at 1024×768, it only occupies about 1/10. Therefore, if px is used as the unit when defining the font size, once the user changes the display resolution from 800 to 1024, the text actually seen by the user will become "smaller" (natural length unit), and may even be unclear, affecting Browse. 2. Em is %, which is a relative unit and a relative unit of length. It originally referred to the width of the letter M, hence the name em. Now it refers to the multiple of the character width, and its usage is similar to a percentage, such as: 0.8em, 1.2em, 2em, etc. Usually 1em=16px. , a universal unit generally used to measure length (such as the margins and padding of elements). When used to specify font sizes, the em unit refers to the font size of the parent element. 3. pt is the abbreviation of point (pound), which is a fixed length measurement unit with a size of 1/72 inch. If you use pt as the unit of text on the web, the font size will be the same on different screens (same resolution), which may have an impact on typesetting, but it is very convenient to use pt in Word. Because the main purpose of using Word is not for screen browsing, but for output and printing. When printing to an entity, pt is convenient and practical as a natural length unit: for example, ordinary documents in Word use "Song font 9pt", titles use "Helvetica 16pt", etc. No matter how the computer is set, it will always be this big when printed. . Recommended learning: html video tutorial The above is the detailed content of How to change font color in html. For more information, please follow other related articles on the PHP Chinese website!How to change font color in html