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

How to set html font color

藏色散人
Release: 2023-01-03 09:26:23
Original
58631 people have browsed it

HTML font color setting method: 1. Set through external CSS style, code such as ".blue{color:blue;}"; 2. Set through internal CSS style, code such as "style="color: white;font-size:25px;""; 3. Set through the font tag.

How to set html font color

The operating environment of this tutorial: windows7 system, HTML5&&CSS3 version, DELL G3 computer. This method is suitable for all brands of computers.

HTML is mainly used to write page layouts. During 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. Through external CSS style to set. 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 and other start tags. The code is implemented as follows:

How to set html font color

#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:

How to set html font color

[Recommended: HTML video tutorial]

3. Set through the font tag. In the content of other tags 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:

How to set html font color

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. .

The above is the detailed content of How to set html font color. 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