HTML 的顏色表示可分兩種:
● 以命名方式定義常用的顏色,如 RED。
● 以 RGB 值表示,如 #FF0000 表示 red。
命名方式涵括的色種不多亦不甚方便,較少采用,以下介紹 RGB 值的原理:
眾所皆知顏色是由 "red" "green" "blue" 三原色組合而成的,在 HTML 中對於彩度的定義是 采十六進位的,對於三原色 HTML 分別給予兩個十六進位去定義,也就是每個原色可有 256 種彩度,故此三原色可混合成一千六佰多萬的顏色。
例如
白色的組成是 red=ff, green=ff, blue=ff, RGB 值即為 ffffff
紅色的組成是 red=ff, green=00, blue=00, RGB 值即為 ff0000
綠色的組成是 red=00, green=ff, blue=00, RGB 值即為 00ff00
藍色的組成是 red=00, green=00, blue=ff, RGB 值即為 0000ff
黑色的組成是 red=00, green=00, blue=00, RGB 值即為 000000
於應用時常在每個 RGB 值之前加上符號 # 以示分別,但不加亦可。
■ HTML 基本架構:
選按不同顏色按鍵以測試前景顏色效果 (只適合 Internet Explorer)
選按不同顏色按鍵以測試背景顏色效果■ 16 常用顏色表:
ColorValueName ColorValueName #00FFFFaqua #808080gray #000080navy #C0C0C0silver #000000black #008000green #808000olive #008080teal #0000FFblue #00FF00lime #800080purple #FFFF00yellow #FF00FFfuchsia #800000maroon #FF0000red #FFFFFFwhite
■ 其它常用顏色表:
ColorValueName ColorValueName #F0F8FFaliceblue #A00000antiquewith #7FFFD4aquamarine #F0FFFFazure #F5F5DCbeige #FFE4C4bisque #000000black #FFEBCDblanchedalmond #0000FFblue #8A2BE2blueviolet #A52A2Abrown #DEB887burlywood #5F9EA0cadetblue #7FFF00chartreuse #D2691Echocolate #FF7F50coral #C0F000cornfloewrblue #FFF8DCcornsilk #00FFFFcyan #00008Bdarkblue #008B8Bdarkcyan #B8860Bdarkgoldenrod #A9A9A9darkgray #006400darkgreen #DA0000darkhaki #8B008Bdarkmagenta #556B2Fdarkolivegreen #DA000Edarkorenge #9932CCdarkorchid #8B0000darkred #E9967Adarksalmon #8FBC8Fdarkseagreen #483D8Bdarkslateblue #2F4F4Fdarkslategray #00CED1darkturquoise #9400D3darkviolet #FF1493deeppink #00BFFFdeepskyblue #696969dimgray #1E90FFdodgerblue #B22222firebrick #FFFAF0floralwhite #228B22forestgreen #DCDCDCgainsboro #00000Egostwhite #FFD700gold #00E00Dgolenrod #808080gray #008000green #ADFF2Fgreenyellow #F0FFF0honeydew #FF69B4hotpink #CD5C5Cindianred #FFFFF0ivory #F0E68Ckhaki #E6E6FAlavender #FFF0F5lavenderblush #7CFC00lawngreen #FFFACDlemonchiffon #ADD8E6lightblue #F08080lightcoral #E0FFFFlightcyan #0000E0lightgodenrod #0000E0lightgodenrodyellow #0000A0lightgray #90EE90lightgreen #FFB6C1lightpink #FFA07Alightsalmon #20B2AAlightseagreen #87CEFAlightskyblue #0000EBlightslateblue #778899lightslategray #B0C4DElightsteelblue #FFFFE0lightyellow #32CD32limegreen #FAF0E6linen #FF00FFmagenta #800000maroon #66CDAAmediumaquamarine #0000CDmediumblue #BA55D3mediumorchid #ED0000mediumpurpul #3CB371mediumseagreen #7B68EEmediumslateblue #00FA9Amediumspringgreen #48D1CCmediumturquoise #C71585mediumvioletred #191970midnightblue #F5FFFAmintcream #FFE4E1mistyrose #FFE4B5moccasin #FFDEADnavajowhite #000080navy #A0B0E0navyblue #FDF5E6oldlace #6B8E23olivedrab #FFA500orange #0E0EEDorengered #DA70D6orchid #A00D00palegodenrod #98FB98palegreen #AFEEEEpaleturquoise #DB7093palevioletred #FFEFD5papayawhip #FFDAB9peachpuff #CD853Fperu #FFC0CBpink #DDA0DDplum #B0E0E6powderblue #800080purple #FF0000red #BC8F8Frosybrown #4169E1royalblue #8B4513saddlebrown #FA8072salmon #F4A460sandybrown #2E8B57seagreen #FFF5EEseashell #A0522Dsienna #87CEEBskyblue #6A5ACDslateblue #708090slategray #FFFAFAsnow #00FF7Fspringgreen #4682B4steelblue #D2B48Ctan #D8BFD8thistle #FF6347tomato #40E0D0turquoise #EE82EEviolet #00E0EDvioletred #F5DEB3wheat #000E00hite #F5F5F5whitesmoke #FFFF00yellow