Html 简明教程
HTML - HEX Colors
HTML HEX 颜色用于十六进制值定义网页颜色,一个使用 16 个符号的数字系统:0-9 和 A-F。
HTML HEX colors are used to define web page colors with hexadecimal values, a number system utilizing 16 symbols: 0-9 and A-F.
HEX Color Codes in HTML
每个 HEX 颜色代码以井号 (#) 开头,包括六个数字。前两个数字指定红色分量,接下来的两个数字指示绿色分量,最后两个数字代表蓝色分量。这种方法允许针对网页设计进行精确的色彩定制。
Each HEX color code starts with a hash sign (#) and includes six digits. The first two digits specify the red component, the next two indicate the green component, and the final two represent the blue component. This method allows precise color customization for web design.
要在 HTML 中使用 hex 颜色,我们可以使用 * style attribute* 直接将它们分配给元素,或者使用颜色属性在 * style* 标签或样式表中定义它们。
To use hex colors in HTML, we can either assign them directly to an element using the style attribute, or define them in a style tag or sheet using the color property.
<element style="color: #FFFFFF;">
Hexadecimal Color Codes
以下是使用十六进制表示法的一些颜色的列表:
Following is a list of few colors using hexadecimal notation:
Color |
Color HEX |
#000000 |
|
#FF0000 |
|
#00FF00 |
|
#0000FF |
|
#FFFF00 |
|
#00FFFF |
|
#FF00FF |
|
#C0C0C0 |
|
#FFFFFF |
Examples of HTML Hex Colors
以下是几个示例,演示如何使用十六进制颜色在 HTML 页面中。
Here are some example that shows how to use Hexadecimal Colors in HTML pages.
Setting Background Color for Body
以下是一个使用十六进制颜色代码设置 HTML 标签背景的示例。
Here is an example to set background of HTML tags by color code in hexadecimal.
<!DOCTYPE html>
<html>
<head>
<title>
HTML Colors by HEX code
</title>
</head>
<body style="background-color: #00FF00;">
<p>
Use different color code for body
and table and see the result.
</p>
<p style="color: #FFFFFF;">
This text will appear white on
black background.
</p>
</body>
</html>
Setting Color on Table Cells
这是另一个演示如何使用 HEX 代码的示例。
This is another example that demonstrates use of HEX code.
<!DOCTYPE html>
<html>
<head>
<title>
HTML HEX Color code
</title>
</head>
<body style="width:300px; height:100px;">
<h2 style="background-color: #FF6666;">
Setting the Background using HEX Code
</h2>
<table style="background-color: #FF3335;">
<tr>
<td style="color: #FFFFFF;">
The text color of the paragraph is
styled using HEX code.
</td>
</tr>
</table>
</body>
</html>
Conclusion
为网页设计选择正确的颜色是困难的。即使你心中有一个颜色,你也需要让计算机理解颜色的十六进制值。为了让你的工作更容易,我们建议使用我们的 * HTML color picker tool.*
Selecting right colors for designing a webpage is difficult. Even if you have a color in your mind, You need to make a computer understand hexadecimal value of color. To make your job easier we suggests using our HTML color picker tool.