HTML 中的顏色名稱在 Web 和應用程式設計過程中扮演著非常重要的角色。它有助於改變我們網站或應用程式的外觀和感覺,並使我們的應用程式更具吸引力和互動性。有多種方法可以將 HTML 中的顏色名稱定義為 HTML 編碼格式。可以使用額外的 CSS 屬性來更有效地使用它。我們可以透過將 HTML 顏色名稱包含在正文部分中來在頁面層級使用 HTML 顏色名稱,也可以為特定元素設定單獨的顏色。 HTML 中的顏色名稱專門用於文字顏色、背景顏色、邊框顏色、陰影、漸層等。
文法
- 我們可以透過多種方式使用 HTML 顏色。我們來一一看看。
- HTML 顏色最基本的用途是將其應用於文字。只需用作文字顏色即可以不同的 HTML 顏色顯示文字。
1.文字顏色文法
color : color_name;
讓我們看看這個語法是如何運作的,
<h4 id="Welcome-to-EDUBCA-h">Welcome to EDUBCA<h4></h4> </h4>
在上面的範例中,它將以藍色顯示文字“Welcome to EDUBCA”,例如:
- 借助 HTML 顏色,也可以將它們新增為背景顏色。
2.背景顏色文法
background-color:color_name;
讓我們看看這個文法是如何運作的,
<p style="background-color:light-green;"></p>
此類別包含設計課程中眾多子類別中的所有設計資訊。
- 也可以透過使用以下語法使用 HTML 顏色在任何文字或元素周圍添加彩色邊框:
3.邊框顏色語法:border
value color_name;
讓我們看看這個文法是如何運作的,
<h4 id="EDUCBA-free-certification-course"> EDUCBA free certification course </h4>
HTML 中顏色名稱的型別
在 HTML 中定義顏色名稱有不同的方法。記住不同顏色的不同名字是很困難的。因此需要決定為不同的顏色賦予一些值。我們來一一看看。
1. RGB 值
- 這是在紅、綠、藍顏色格式值的組合中定義 HTML 顏色名稱的方法之一。它用於定義數字 0 到 255 之間的顏色強度?
- 如果我們想使用 RGB 組合來定義黑色,則類似於 RGB(0,0,0)。這裡所有的顏色參數都會設定為0。所以它會顯示黑色。
- 就像另一個RGB(0,0,255)會顯示藍色,因為255被設定為藍色的最高值,另一個是0。
- 如果我們要使用 3 個相等的 RGB 值,那麼它將產生灰色陰影。
範例: RGB (0,0,0) 表示最暗的顏色,RGB(255,255,255) 表示最淺的顏色。
2.十六進位值
- 它是 HTML 中最常用的顏色名稱格式之一,其中顏色名稱將以十六進位值的格式定義。
- #rrggbb 格式包括 RR 表示紅色、gg 表示綠色和 bb 表示藍色的值,這些值放置在 00 toff 十六進位值之間。
- 讓我們考慮一個定義顏色 #00ff00 的範例。這些值將產生綠色,因為綠色包含最高值(ff),而另一個值設定為 00。
3.福彩價值
- 另一種以色調、飽和度、亮度形式定義 HTML 顏色的格式。
- 現在我們將一一查看所有術語。色調定義為 0 到 360 之間的顏色程度。 0 表示紅色,120 表示綠色,240 表示藍色。
- 飽和度將顏色的值定義為百分比,其中 0% 表示灰色陰影,100% 表示全彩。
- 亮度也可以用作百分比,它定義 0% 為黑色,50% 既不亮也不暗,100% 表示白色。
4. RGBA 值
- 這種類型的 HTML 顏色定義了 RGB 顏色的擴展,包括 alpha 值,其中 alpha 用於定義顏色的不透明度。
- Alpha 值介於 0.0 {完全透明}到 1.0 {完全不透明}
- 範例是 rgba(255,99,71,0)
5. HSLA 值
- 它的工作原理與 HSL 顏色值相同,用於定義顏色的不透明度。
- hsla(8,100%,80%,0) 用於完全透明的顏色。
- hsla(8,100%,80%,0.9) 較不透明的顏色。
使用 HTML 顏色名稱
在網頁上實現顏色非常簡單,可以內聯或透過單獨的 CSS 樣式表完成。
When you are going to be using the same HTML Color Names on a page multiple times, it is a better idea to use CSS Sheet to define and set colors. Conversely, if you only have to use color once or twice, using the inline method is considered better.
1. Using HTML Color Inline
<h3 id="Brown-H-Heading">Brown H3 Heading</h3> <p style="color: Gainsboro">Gainsboro colored paragraph text</p>
2. Implementing in CSS
h1 { color: Brown; } p { color: Gainsboro; }
Different HTML Color Codes
Colors can be denoted by using their hex value or their name. HTML has support for the most common colors; in this article, I will share with you 140 names and hex values of these colors. One thing to keep in mind is that you don’t have to limit yourself to these colors; you can use any color picker tool to find the Hex value of any color you want and use it on your web page.
Now that you know what HTML Color Names are and how you can use them in your pages, here is a list of Color names with appropriate color codes:
1. Grey and Black HTML Color Names
Grey and Black colors are, in most cases, perfect for the text color of the page as against a white background; these colors have the best readability. One interesting thing to keep in mind is that modern phones with OLED displays done need any battery power to display Black color; if your audience is going to be on mobile, it is a wise idea to use Black as a background color and white or other light colors as the foreground color.
Code | Color |
#000000 | Black |
#0C090A | Night |
#2C3539 | Gunmetal |
#2B1B17 | Midnight |
#34282C | Charcoal |
#25383C | Dark Slate Grey |
#3B3131 | Oil |
#413839 | Black Cat |
#3D3C3A | Iridium |
#463E3F | Black Eel |
#4C4646 | Black Cow |
#504A4B | Gray Wolf |
#565051 | Vampire Gray |
#5C5858 | Gray Dolphin |
#625D5D | Carbon Gray |
#666362 | Ash Gray |
#6D6968 | Cloudy Gray |
#726E6D | Smokey Gray |
#736F6E | Gray |
#837E7C | Granite |
#848482 | Battleship Gray |
#B6B6B4 | Gray Cloud |
#D1D0CE | Gray Goose |
#E5E4E2 | Platinum |
#BCC6CC | Metallic Silver |
#98AFC7 | Blue Gray |
#6D7B8D | Light Slate Gray |
#657383 | Slate Gray |
#616D7E | Jet Gray |
2.藍色 HTML 顏色名稱
藍色下劃線文本被視為鏈接,因為它是大多數網絡瀏覽器的默認鏈接樣式,您應該避免在頁面上的所有文本中使用藍色,因為訪問者可能會將其誤認為是超鏈接。
#646D7E | Mist Blue |
#566D7E | Marble Blue |
#737CA1 | Slate Blue |
#4863A0 | Steel Blue |
#2B547E | Blue Jay |
#2B3856 | Dark Slate Blue |
#151B54 | Midnight Blue |
#000080 | Navy Blue |
#342D7E | Blue Whale |
#15317E | Lapis Blue |
#151B8D | Denim Dark Blue |
#0000A0 | Earth Blue |
#0020C2 | Cobalt Blue |
#0041C2 | Blueberry Blue |
#2554C7 | Sapphire Blue |
#1569C7 | Blue Eyes |
#2B60DE | Royal Blue |
#1F45FC | Blue Orchid |
#6960EC | Blue Lotus |
#736AFF | Light Slate Blue |
#357EC7 | Windows Blue |
#368BC1 | Glacial Blue Ice |
#488AC7 | Silk Blue |
#3090C7 | Blue Ivy |
#659EC7 | Blue Koi |
#87AFC7 | Columbia Blue |
#95B9C7 | Baby Blue |
#728FCE | Light Steel Blue |
#2B65EC | Ocean Blue |
#306EFF | Blue Ribbon |
#157DEC | Blue Dress |
#1589FF | Dodger Blue |
#6495ED | Cornflower Blue |
#6698FF | Sky Blue |
#38ACEC | Butterfly Blue |
#56A5EC | Iceberg |
#5CB3FF | Crystal Blue |
#3BB9FF | Deep Sky Blue |
#79BAEC | Denim Blue |
#82CAFA | Light Sky Blue |
#82CAFF | Day Sky Blue |
#A0CFEC | Jeans Blue |
#B7CEEC | Blue Angel |
#B4CFEC | Pastel Blue |
#C2DFFF | Sea Blue |
#C6DEFF | Powder Blue |
#AFDCEC | Coral Blue |
#ADDFFF | Light Blue |
#BDEDFF | Robin Egg Blue |
#CFECEC | Pale Blue Lily |
#E0FFFF | Light Cyan |
#EBF4FA | Water |
#F0F8FF | AliceBlue |
#F0FFFF | Azure |
#CCFFFF | Light Slate |
#93FFE8 | Light Aquamarine |
#9AFEFF | Electric Blue |
#7FFFD4 | Aquamarine |
#00FFFF | Cyan or Aqua |
#7DFDFE | Tron Blue |
#57FEFF | Blue Zircon |
#8EEBEC | Blue Lagoon |
#50EBEC | Celeste |
#4EE2EC | Blue Diamond |
#81D8D0 | Tiffany Blue |
#92C7C7 | Cyan Opaque |
#77BFC7 | Blue Hosta |
#78C7C7 | Northern Lights Blue |
#48CCCD | Medium Turquoise |
#43C6DB | Turquoise |
#46C7C7 | Jellyfish |
#7BCCB5 | Blue green |
3.綠色 HTML 顏色
在與自然、金錢、環境等相關的網站上,綠色可以作為背景顏色的好選擇。
#43BFC7 | Macaw Blue Green |
#3EA99F | Light Sea Green |
#3B9C9C | Dark Turquoise |
#438D80 | Sea Turtle Green |
#348781 | Medium Aquamarine |
#307D7E | Greenish Blue |
#5E7D7E | Grayish Turquoise |
#4C787E | Beetle Green |
#008080 | Teal |
#4E8975 | Sea Green |
#78866B | Camouflage Green |
#848b79 | Sage Green |
#617C58 | Hazel Green |
#728C00 | Venom Green |
#667C26 | Fern Green |
#254117 | Dark Forest Green |
#306754 | Medium Sea Green |
#347235 | Medium Forest Green |
#437C17 | Seaweed Green |
#387C44 | Pine Green |
#347C2C | Jungle Green |
#347C17 | Shamrock Green |
#348017 | Medium Spring Green |
#4E9258 | Forest Green |
#6AA121 | Green Onion |
#4AA02C | Spring Green |
#41A317 | Lime Green |
#3EA055 | Clover Green |
#6CBB3C | Green Snake |
#6CC417 | Alien Green |
#4CC417 | Green Apple |
#52D017 | Yellow Green |
#4CC552 | Kelly Green |
#54C571 | Zombie Green |
#99C68E | Frog Green |
#89C35C | Green Peas |
#85BB65 | Dollar Bill Green |
#8BB381 | Dark Sea Green |
#9CB071 | Iguana Green |
#B2C248 | Avocado Green |
#9DC209 | Pistachio Green |
#A1C935 | Salad Green |
#7FE817 | Hummingbird Green |
#59E817 | Nebula Green |
#57E964 | Stoplight Go Green |
#64E986 | Algae Green |
#5EFB6E | Jade Green |
#00FF00 | Green |
#5FFB17 | Emerald Green |
#87F717 | Lawn Green |
#8AFB17 | Chartreuse |
#6AFB92 | Dragon Green |
#98FF98 | Mint green |
#B5EAAA | Green Thumb |
#C3FDB8 | Light Jade |
#CCFB5D | Tea Green |
#B1FB17 | Green Yellow |
#BCE954 | Slime Green |
#EDDA74 | Goldenrod |
#EDE275 | Harvest Gold |
#FFE87C | Sun Yellow |
4.黃色 HTML 顏色名稱
黃色可以用來營造一種不嚴肅的情緒,在頁面中展現創造力和樂觀情緒。請記住,黃色作為背景顏色比文字顏色效果更好。
#FFFF00 | Yellow |
#FFF380 | Corn Yellow |
#FFFFC2 | Parchment |
#FFFFCC | Cream |
#FFF8C6 | Lemon Chiffon |
#FFF8DC | Cornsilk |
#F5F5DC | Beige |
#FBF6D9 | Blonde |
#FAEBD7 | AntiqueWhite |
#F7E7CE | Champagne |
#FFEBCD | BlanchedAlmond |
#F3E5AB | Vanilla |
#ECE5B6 | Tan Brown |
#FFE5B4 | Peach |
#FFDB58 | Mustard |
#FFD801 | Rubber Ducky Yellow |
#FDD017 | Bright Gold |
#EAC117 | Golden brown |
#F2BB66 | Macaroni and Cheese |
#FBB917 | Saffron |
#FBB117 | Beer |
#FFA62F | Cantaloupe |
#E9AB17 | Bee Yellow |
5.棕色 HTML 顏色
棕色背景會使閱讀白色或黑色文字變得困難,您可以使用與棕色陰影形成良好對比的其他顏色。
#E2A76F | Brown Sugar |
#DEB887 | BurlyWood |
#FFCBA4 | Deep Peach |
#C9BE62 | Ginger Brown |
#E8A317 | School Bus Yellow |
#EE9A4D | Sandy Brown |
#C8B560 | Fall Leaf Brown |
#D4A017 | Orange Gold |
#C2B280 | Sand |
#C7A317 | Cookie Brown |
#C68E17 | Caramel |
#B5A642 | Brass |
#ADA96E | Khaki |
#C19A6B | Camel brown |
#CD7F32 | Bronze |
#C88141 | Tiger Orange |
#C58917 | Cinnamon |
#AF9B60 | Bullet Shell |
#AF7817 | Dark Goldenrod |
#B87333 | Copper |
#966F33 | Wood |
#806517 | Oak Brown |
#827839 | Moccasin |
#827B60 | Army Brown |
#786D5F | Sandstone |
#493D26 | Mocha |
#483C32 | Taupe |
#6F4E37 | Coffee |
#835C3B | Brown Bear |
#7F5217 | Red Dirt |
#7F462C | Sepia |
6.橘色 HTML 顏色
橙色作為背景色可以很好地突出一點,既能喚起熱情和溫暖的感覺,又不會太俗氣。 6.橙色 HTML 顏色
#C47451 | Orange Salmon |
#C36241 | Rust |
#C35817 | Red Fox |
#C85A17 | Chocolate |
#CC6600 | Sedona |
#E56717 | Papaya Orange |
#E66C2C | Halloween Orange |
#F87217 | Pumpkin Orange |
#F87431 | Construction Cone Orange |
#E67451 | Sunrise Orange |
#FF8040 | Mango Orange |
#F88017 | Dark Orange |
#FF7F50 | Coral |
#F88158 | Basket Ball Orange |
#F9966B | Light Salmon |
#E78A61 | Tangerine |
#E18B6B | Dark Salmon |
#E77471 | Light Coral |
#F75D59 | Bean Red |
#E55451 | Valentine Red |
#E55B3C | Shocking Orange |
7.紅色 HTML 顏色代碼
對於某些瀏覽器,紅色下劃線文字用作訪問過的鏈接,您應該避免使用它,以免迷惑訪問者。
#FF0000 | Red |
#FF2400 | Scarlet |
#F62217 | Ruby Red |
#F70D1A | Ferrari Red |
#F62817 | Fire Engine Red |
#E42217 | Lava Red |
#E41B17 | Love Red |
#DC381F | Grapefruit |
#C34A2C | Chestnut Red |
#C24641 | Cherry Red |
#C04000 | Mahogany |
#C11B17 | Chilli Pepper |
#9F000F | Cranberry |
#990012 | Red Wine |
#8C001A | Burgundy |
#954535 | Chestnut |
#7E3517 | Blood Red |
#8A4117 | Sienna |
#7E3817 | Sangria |
#800517 | Firebrick |
#810541 | Maroon |
#7D0541 | Plum Pie |
#7E354D | Velvet Maroon |
#7D0552 | Plum Velvet |
#7F4E52 | Rosy Finch |
#7F5A58 | Puce |
#7F525D | Dull Purple |
#B38481 | Rosy Brown |
#C5908E | Khaki Rose |
8.粉紅色 HTML 顏色代碼
根據色彩科學,如果您想讓訪客在潛意識中感受到自信、成熟和溫暖,可以使用粉紅色及其色調。
#C48189 | Pink Bow |
#C48793 | Lipstick Pink |
#E8ADAA | Rose |
#ECC5C0 | Rose Gold |
#EDC9AF | Desert Sand |
#FDD7E4 | Pig Pink |
#FCDFFF | Cotton Candy |
#FFDFDD | Pink Bubble Gum |
#FBBBB9 | Misty Rose |
#FAAFBE | Pink |
#FAAFBA | Light Pink |
#F9A7B0 | Flamingo Pink |
#E7A1B0 | Pink Rose |
#E799A3 | Pink Daisy |
#E38AAE | Cadillac Pink |
#F778A1 | Carnation Pink |
#E56E94 | Blush Red |
#F660AB | Hot Pink |
#FC6C85 | Watermelon Pink |
#F6358A | Violet Red |
#F52887 | Deep Pink |
#E45E9D | Pink Cupcake |
#E4287C | Pink Lemonade |
#F535AA | Neon Pink |
#FF00FF | Magenta |
#E3319D | Dimorphotheca Magenta |
#F433FF | Bright Neon Pink |
#D16587 | Pale Violet Red |
#C25A7C | Tulip Pink |
#CA226B | Medium Violet Red |
#C12869 | Rogue Pink |
#C12267 | Burnt Pink |
#C25283 | Bashful Pink |
#C12283 | Dark Carnation Pink |
#B93B8F | Plum |
9.紫色和白色 HTML 顏色代碼
在白色背景上使用白色文字顏色將使其無法被使用者閱讀,除了使用者不友善之外,您的網站可能會受到SEO 懲罰,因此,請始終在深色背景下使用白色和其他淺色。
#7E587E | Viola Purple |
#571B7E | Purple Iris |
#583759 | Plum Purple |
#4B0082 | Indigo |
#461B7E | Purple Monster |
#4E387E | Purple Haze |
#614051 | Eggplant |
#5E5A80 | Grape |
#6A287E | Purple Jam |
#7D1B7E | Dark Orchid |
#A74AC7 | Purple Flower |
#B048B5 | Medium Orchid |
#6C2DC7 | Purple Amethyst |
#842DCE | Dark Violet |
#8D38C9 | Violet |
#7A5DC7 | Purple Sage Bush |
#7F38EC | Lovely Purple |
#8E35EF | Purple |
#893BFF | Aztech Purple |
#8467D7 | Medium Purple |
#A23BEC | Jasmine Purple |
#B041FF | Purple Daffodil |
#C45AEC | Tyrian Purple |
#9172EC | Crocus Purple |
#9E7BFF | Purple Mimosa |
#D462FF | Heliotrope Purple |
#E238EC | Crimson |
#C38EC7 | Purple Dragon |
#C8A2C8 | Lilac |
#E6A9EC | Blush Pink |
#E0B0FF | Mauve |
#C6AEC7 | Wisteria Purple |
#F9B7FF | Blossom Pink |
#D2B9D3 | Thistle |
#E9CFEC | Periwinkle |
#EBDDE2 | Lavender Pinocchio |
#E3E4FA | Lavender blue |
#FDEEF4 | Pearl |
#FFF5EE | SeaShell |
#FEFCFF | Milk White |
#FFFFFF | White |
一些最常用的 HTML 顏色代碼
這些是網路上使用的一些流行顏色;我已將它們放在單獨的表中以便快速找到它們。
Red | #FF0000 | White | #FFFFFF |
Cyan | #00FFFF | Silver | #C0C0C0 |
Blue | #0000FF | Gray or Grey | #808080 |
DarkBlue | #0000A0 | Black | #000000 |
LightBlue | #ADD8E6 | Orange | #FFA500 |
Purple | #800080 | Brown | #A52A2A |
Yellow | #FFFF00 | Maroon | #800000 |
Lime | #00FF00 | Green | #008000 |
Magenta | #FF00FF | Olive | #808000 |
Examples of Color Name in HTML
Let us see how color name in HTML is used with the help of some examples mentioned below:
Example #1
Let us consider a general example showing how example color name in HTML is going to be used:
HTML code:
<h1 id="About-Life">About Life.....</h1> <h4 id="Creativity-Is-Intelligence-Having-Fun">Creativity Is Intelligence Having Fun </h4> <p style="background-color: #00FFFF; color:blue"></p>
You Learn More From Failure Than From Success. Don’t Let It Stop You. Failure Builds Character. If You Are Working On Something That You Really Care About, You Don’t Have To Be Pushed. The Vision Pulls You
Output:
Example #2
Now we are taking another example which will define all types of HTML color as follows:
HTML code:
<h1 id="RGB-defines-Red-color">RGB defines Red color</h1> <h1 id="RGB-same-values-define-Gray-shade">RGB same values define Gray shade</h1> <h1 id="New-color-using-Hex-Value">New color using Hex Value</h1> <h1 id="Shade-of-Gray">Shade of Gray</h1> <h1 id="hsl-color-shade">hsl color shade</h1> <h1 id="rgba-color-shade">rgba color shade</h1> <h1 id="hsla-color-shade">hsla color shade</h1>
Output:
In the above example, we are able to see the use of different HTML color types and how they are named in HTML.
Example #3
One more use of HTML color is to define a border to the element, which is as follows:
In Example, Here, we can add a border to your code body, changing the background and text colour.
HTML code:
<p style="border: 2px solid #A52A2A; background-color:#ffa500;color:#FFF8DC">Self-actualizing theory talks of intrinsic rewards inherent in the task performance such as job satisfaction, feeling of achievement, etc.</p>
Output:
Conclusion
We came across that HTML colors are defined with different names, percentage value, Hex value, alpha value, and many more. Color name in HTML is used to do color for text, for background, for a border, for gradations. Different types define HTML color name as RGB, hex, hsl, rgba, hsla.
以上是HTML 中的顏色名稱的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本篇文章带大家了解一下HTML(超文本标记语言),介绍一下HTML的本质,HTML文档的结构、HTML文档的基本标签和图像标签、列表、表格标签、媒体元素、表单,希望对大家有所帮助!

不算。html是一种用来告知浏览器如何组织页面的标记语言,而CSS是一种用来表现HTML或XML等文件样式的样式设计语言;html和css不具备很强的逻辑性和流程控制功能,缺乏灵活性,且html和css不能按照人类的设计对一件工作进行重复的循环,直至得到让人类满意的答案。

总结了一些web前端面试(笔试)题分享给大家,本篇文章就先给大家分享HTML部分的笔试题(附答案),大家可以自己做做,看看能答对几个!

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

在html中,document是文档对象的意思,代表浏览器窗口的文档;document对象是window对象的子对象,所以可通过“window.document”属性对其进行访问,每个载入浏览器的HTML文档都会成为Document对象。

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

3种取消方法:1、给td元素添加“border:none”无边框样式即可,语法“td{border:none}”。2、给td元素添加“border:0”样式,语法“td{border:0;}”,将td边框的宽度设置为0即可。3、给td元素添加“border:transparent”样式,语法“td{border:transparent;}”,将td边框的颜色设置为透明即可。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Dreamweaver CS6
視覺化網頁開發工具

記事本++7.3.1
好用且免費的程式碼編輯器

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境