HTML Colors
Dive into the vibrant world of HTML colors and learn how to add visual appeal to your web pages
Understanding the vibrant world of colors is an essential skill for any web designer venturing into the realm of HTML. With an impressive palette of over 16 million colors at your disposal, you have the power to transform a plain and monochromatic webpage into a visually captivating experience.
Delve into the fundamental principles of color theory and discover how to select the perfect hues, shades, and tints to evoke the desired emotions and create harmonious compositions. From mastering the art of defining colors using hexadecimal values to exploring the various CSS color properties and their applications, you will develop a deep understanding of how to infuse your HTML pages with captivating colors that enchant and engage your audience.
The style
attribute helps us decorate style
modify text style="color:blue;"
tells the browser that the element should be blue. The color
here is a CSS property, while blue
is its value.
Stick to the standard HTML and CSS syntax to display changes properly:
• An equals sign (=) after style
• A colon (:) to separate the two parts
• Quotation marks (" ") to wrap the color
property
• A semicolon (;) after the CSS value
Let's say you need to put some colored background beneath your text. Here comes another background-color
. The syntax is the same as that of the text style="background-color:powderblue;"
. Instead of powderblue
value, you can insert any color name or its RGB, HSL, HEX, RGBA, or HSLA value.
Pro Tip: Don't forget to meet accessibility requirements and maintain the contrast ratio of 4.5:1 for normal-sized text and its background and 3:1 for larger text such as headings.
Like the border
style
attribute. You can set the border style, width, and color — the order matters — and those settings will apply to all border sides. For example, the syntax can be written as follows: style="border:solid 4px blue;"
.
Just like people, colors have names and "ID numbers." RGB <h1 style="background-color:rgb(32, 178, 170);">...</h1>.
HEX codes are more compact and improve the load time of a web style="color:#ff6347;"
.
HSL is another
Pro Tip: Play around with the opacity of layers to add a sense of depth, modify contrast, and create unusual visual effects.
RGBA style="color:rgba(255, 99, 71, 0.5);"
.
HSLA is a modified HSL version with an hsla()
functional notation to set values: style="color: hsla(360,80%,50%,0.5);"
. A quick reminder — avoid any spacing in between characters.
In
There are several gray
In RGB abbreviation, "R" stands for red. The
To display black, you should reduce red, green, and blue to their lowest values — RGB (0, 0, 0). The good news is that the
Pure black is an intense
To display white, we should set all parameters to the highest values of 255.
In design, white sets a neutral scenery, allowing other