HTML顏色

HTML顏色 HTML colors

HTML colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values.
詳細(xì)的顏色設(shè)置和數(shù)值,參見https://www.w3schools.com/colors/default.asp

<h1 style="background-color:rgb(255, 99, 71);">...</h1>
<h1 style="background-color:#ff6347;">...</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">...</h1>
<h1 style="background-color:rgba(255, 99, 71, 0.5);">...</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">...</h1>

Color names

HTML supports 140 standard color names.
Background color

<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">Lorem ipsum...</p>

Text color

<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p>

Border color

<h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>

RGB

rgb(red紅, green綠, blue藍(lán))

Each parameter (red, green, and blue) defines the intensity of the color between 0 and 255.

For example, rgb(255, 0, 0) is displayed as red, because red is set to its highest value (255) and the others are set to 0.

To display the color black, all color parameters must be set to 0, like this: rgb(0, 0, 0).

To display the color white, all color parameters must be set to 255, like this: rgb(255, 255, 255).

HEX

In HTML, a color can be specified using a hexadecimal value in the form:

#rrggbb

Where rr (red), gg (green) and bb (blue) are hexadecimal values between 00 and ff (same as decimal 0-255).

For example, #ff0000 is displayed as red, because red is set to its highest value (ff) and the others are set to the lowest value (00).

HSL

In HTML, a color can be specified using hue, saturation, and lightness (HSL) in the form:

hsl(hue色度, saturation飽和度, lightness亮度)

Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue.

Saturation is a percentage value, 0% means a shade of gray, and 100% is the full color.
Saturation can be described as the intensity of a color. 100% is pure color, no shades of gray. 50% is 50% gray, but you can still see the color. 0% is completely gray, you can no longer see the color.

Lightness is also a percentage, 0% is black, 50% is neither light or dark, 100% is white
The lightness of a color can be described as how much light you want to give the color, where 0% means no light (black), 50% means 50% light (neither dark nor light) 100% means full lightness (white).

Shades of gray are often defined by setting the hue and saturation to 0, and adjust the lightness from 0% to 100% to get darker/lighter shades.

RGBA

RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity for a color.

An RGBA color value is specified with:

rgba(red, green, blue, alpha)

The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all).

HSLA

HSLA color values are an extension of HSL color values with an alpha channel - which specifies the opacity for a color.

An HSLA color value is specified with:

hsla(hue, saturation, lightness, alpha)

The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all).

HTML顏色頁面參見:
https://www.w3schools.com/html/html_colors.asp

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,872評論 0 10
  • 最近這段時(shí)間在搞openGL ES處理視頻和圖像,要進(jìn)行紋理混合,重新溫習(xí)了一下大學(xué)時(shí)候的課本,找了一些資料,把一...
    北冥有貓其名為喵閱讀 34,611評論 5 19
  • 很多有故事的長輩都會(huì)語重心長地說道:當(dāng)下你正在經(jīng)歷的事情或者經(jīng)歷過的事情都是你唯一要經(jīng)歷的。 最近有人說...
    Summer_86b0閱讀 403評論 1 1
  • iOS中的多線程解決方案: Pthreads NSThread GCD NSOperation & NSOpera...
    火焰與檸檬閱讀 263評論 0 0
  • 承擔(dān)起生活的重?fù)?dān),不叫勇氣,敢于去過自己想過的生活,才叫勇氣。 我們現(xiàn)在有多少人過的是自己想要的生活?大家都是在忙...
    隨風(fēng)遠(yuǎn)閱讀 446評論 0 1

友情鏈接更多精彩內(nèi)容