Table of Contents
这是 heading 1
Home Web Front-end CSS Tutorial How to adjust font color in css

How to adjust font color in css

Mar 01, 2021 pm 03:46 PM
css font color

How to adjust the font color in css: You can use the color attribute to adjust the font color, such as [body {color:red}], which means setting the element font to red. The color attribute is used to set the foreground color of the element, that is, the color of the element's text.

How to adjust font color in css

The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.

Attribute introduction:

The color attribute specifies the color of the text.

This attribute sets the foreground color of an element (in HTML representation, the color of the element's text); raster images are not affected by color. This color also applies to all borders of the element, unless overridden by border-color or another border-color property.

Attribute value:

  • color_name specifies that the color value is the color of the color name (such as red).

  • hex_number specifies the color value as a hexadecimal value (such as #ff0000).

  • rgb_number specifies the color value as the color of the rgb code (such as rgb(255,0,0)).

  • #inherit Specifies that the color should be inherited from the parent element.

(Learning video sharing: css video tutorial)

Example of adjusting font color:

<html>
<head>
<style type="text/css">
body {color:red}
h1 {color:#00ff00}
p.ex {color:rgb(0,0,255)}
</style>
</head>

<body>
<h1 id="这是-nbsp-heading-nbsp">这是 heading 1</h1>
<p>这是一段普通的段落。请注意,该段落的文本是红色的。在 body 选择器中定义了本页面中的默认文本颜色。</p>
<p class="ex">该段落定义了 class="ex"。该段落中的文本是蓝色的。</p>
</body>
</html>
Copy after login

Running results:

How to adjust font color in css

Related recommendations: CSS tutorial

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

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does placeholder mean in vue What does placeholder mean in vue May 07, 2024 am 09:57 AM

What does placeholder mean in vue

How to write spaces in vue How to write spaces in vue Apr 30, 2024 am 05:42 AM

How to write spaces in vue

How to get dom in vue How to get dom in vue Apr 30, 2024 am 05:36 AM

How to get dom in vue

What does span mean in js What does span mean in js May 06, 2024 am 11:42 AM

What does span mean in js

What does rem mean in js What does rem mean in js May 06, 2024 am 11:30 AM

What does rem mean in js

Vivo's new X100 series memory, color exposure: all series start at 12+256GB Vivo's new X100 series memory, color exposure: all series start at 12+256GB May 06, 2024 pm 03:58 PM

Vivo's new X100 series memory, color exposure: all series start at 12+256GB

How to introduce images into vue How to introduce images into vue May 02, 2024 pm 10:48 PM

How to introduce images into vue

What is the function of span tag What is the function of span tag Apr 30, 2024 pm 01:54 PM

What is the function of span tag

See all articles