For working professionals
For fresh graduates
More
Learn HTML: A Comprehensive Tu…
1. HTML Tutorial
2. HTML Basics
3. HTML Syntax
4. HTML Elements
5. HTML Attributes
6. HTML Comments
7. HTML Semantic
8. HTML Form Elements
9. HTML Head
10. HTML Title
11. HTML Styles
12. HTML Paragraphs
13. HTML Symbols
14. HTML Emojis
15. HTML Formatting
16. HTML Entities
17. HTML Audio
18. HTML Images
19. HTML Lists
20. HTML Links
21. SVG in HTML
22. HTML Forms
23. HTML Video
24. HTML Canvas
25. Adjacency Lists
26. HTML Input Types
27. HTML Tables
28. HTML Table Border
29. Cell Spacing and Cell Padding
30. HTML Semantic Elements
31. HTML Layout
32. html blocks and inline
33. HTML Div
34. Difference Between HTML and CSS
35. Image Map in HTML
36. HTML Drag and Drop
37. HTML Iframes
38. Divide and Conquer Algorithm
39. Difference Between HTML and XHTML
40. HTML Code
41. HTML Colors
Now Reading
42. HTML CSS
43. HTML Editors
44. HTML Examples
45. Class in HTML
46. HTML Exercises
47. HTML ID
48. Understanding HTML Encoding: A Comprehensive Guide
49. HTML Table Style
50. HTML Script
51. Introduction to HTML
HTML, aka hypertext markup language, is a standard platform that helps you create the structure of a webpage. It incorporates numerous elements, such as headings, paragraphs, links, colors, images, and so on.
In my journey as a techie, HTML colors were a very important aspect whenever I tried to create a layout for a webpage. This element helped me create and design an attractive webpage by incorporating a subtle blend of colors, and HTML tutorials were a great support in my early days.
In the tutorial, I’ll help you understand where you can apply HTML colors and how they enhance the quality of a webpage.
HTML colors are an attribute provided by the platform to help create and design interactive and attractive layouts for web pages easily. Previously, the HTML color tag used to recognize only 16 colors, namely, black, gray, white, maroon, silver, red, olive, Osia, lime, green, purple, yellow, teal, blue, aqua, and navy. However, with recent developments in the tech industry and the inclusion of new browsers, 147 CSS3 colors can be recognized in HTML expressed in #FF0000 and #FFFFFF format.
I apply HTML colors to backgrounds, tables, texts, borders, forms, links, etc, to design a webpage’s basic structure. You can define them in variations, including specified color names, hexadecimal numbers, RGB, HSL, and RGBA, allowing precise and complete influence on how colors should be displayed on webpages.
HTML colors allow you to experiment with a diverse color palette. I have curated this detailed guide about the various use cases of HTML colors.
One of the main attributes of an HTML color program is the appearance of the background.
The color that appears on a webpage underneath what is displayed is called the HTML background color. Excluding the margin, it is the background that fills the entire webpage that you have created.
To add background color in HTML, use the following syntax:
<div style=”background-color: blue;”>
Div with blue background
</div>
You can add whichever color you want to the text to be displayed on the webpage. You should choose a text color that is appropriate for increasing the readability of the text and which is appealing to the users.
The syntax for adding the text color is:
<p style=”color: white;”>
White color is used
</p>
Another important color attribute in the HTML color list is the color of the border of a webpage. The border color in HTML colors will bring out the desired color to the border lines.
Here is a syntax that you have to use for defining the border color:
<div style=”border: 1px solid black; border-color: black;”>
This div has a black border
</div>
Last but not least, you can incorporate the HTML color code list to highlight a particular link to attract the reader's attention. The link color shall be different from that of the other text on the webpage so visitors can easily differentiate it.
The link color will only demonstrate the color of the anchor tag that the webpage contains. This will help the user to navigate more easily by highlighting the clickable link in a different color.
Use this syntax to add the HTML link color:
<a href=”#” style=”color: blue;”>
Link has a blue color
</a>
You don’t need to master coding to use HTML colors to create a layout for your webpage. All you need is a knowledge of basic programming applicable to HTML.
You can also check interesting HTML project ideas to get you started on your webpage designing journey.
Let me illustrate the various HTML color elements in one single example:
Code:
<!DOCTYPE html>
<html>
<head>
<title>HTML Text Color</title>
<style>
center {
width: 30%;
margin: 0 auto;
}
h2, div, p, span {
padding: 20px;
margin-bottom: 30px;
}
</style>
</head>
<body>
<center>
<h2 style="background-color: Green;">
Heading with Green Background color
</h2>
<div style="border: 5px solid Tomato;">
Div with Tomato Border color
</div>
<span >
<a href="#" style="color: Blue;">
Link has a Blue color
</a>
</span>
<p style="color: Black;">
Paragraph with Black Text color
</p>
</html>
Result:
After you execute the above-mentioned code to apply HTML colors on your webpage, you will notice the result or output in the following manner:
While a variety of colors are available in HTML, certain colors are common and have multiple shades to them.
Here’s presenting the HTML color list containing some of the most common and widely used colors:
HTML color codes list defines the attributes of colors in a particular webpage. When I started my career, I found it challenging to name colors using particular codes, but with time, it became easier. So, if you’re starting your journey as a techie, don't worry. Learning HTML colors step-by-step will make it a cakewalk for you like it did for me.
You can specify the color codes in HTML using hex, RGB, HSL code names, and keywords.
Let’s understand each of them one by one.
The RGB color code, as the name suggests, only works with three primary colors: red, green, and blue. This color value will allow you to define colors based on these three primary colors by adjusting the values from 0 to 225. You can mix and adjust these values to generate a variety of colors and create a diverse color palette.
If you want to apply black color, then all the color attributes have to be set at 0, and in the case of white, you need to set every color parameter at the maximum of 255. Subsequently, you can range the values as per your convenience and liking to generate unique shades of different colors.
Here is the syntax for the RGB color code:
// Green background
<p style="background-color: rgb(0, 255, 0);">
The background is set to Green by using RGB
</p>
The hex code system, which consists of color codes defined in hexadecimal values, uses a six-digit code system. It includes characters made in pairs to specify and define the attributes of colors. You need to understand the CSS; hex values are defined in the form #rrggbb. Here, rr, gg, and bb represent the intensity of the colors red, green, and blue, respectively.
Using the HTML color hex codes, you can create a wide range of color combinations to design a unique webpage. In this color value system, the range is defined from 00 to ff, where ff denotes the maximum intensity, and 00 denotes the minimum intensity of a color.
For instance, if you apply a hex code #00ff00, it denotes no red, max, green, and no blue.
Let me provide the syntax for the hex color code value:
// Blue Background
<div style="background-color: #0000ff;">
div has a blue background by using Hex
</div>
HSL refers to hue, saturation, lightness, and color value in HTML. You will notice that this system does not mainly focus on the primary color but changes the shade by adjusting the hue, saturation, and lightness of the color.
Let me explain this by dividing it into three major heads:
Let’s see the range for each of these attributes while defining a color:
Here’s presenting the syntax for the HSL color code system in HTML:
// Gray Background
<div style="background-color: hsl(0, 0%, 50%);">
This div has a gray background using HSL
</div>
I like how HTML makes it really simple for us to design engaging and dynamic websites. It has been comparatively simpler to grab consumers' attention while they navigate our developed webpage thanks to the wide range of HTML colors. The unique color attributes provided by HTML have increasingly helped developers and tech experts improve their web designing skills including myself.
However, if you wish to learn more about HTML and its usage in the ever-evolving technological world, you can browse through the diverse range of courses offered by upGrad. There are numerous courses that will provide a comprehensive breakdown of all the features connected to HTML to help you succeed in the digital age.
The three popular HTML color coding systems are RGB, HSL, and hex. These systems help users define and create a diversity of colors that will suit their web page.
The range for the HTML RGB color coding standard is 0 to 255. The color values of the hex color coding system run from 00 to ff. Lastly, the HSL range spans from 0% to 100% and from 0° to 360°.
Using the RGB color coding scheme, colors are defined by giving them values between 0 and 255. Red, green, and blue are the three fundamental colors from which all other colors are derived.
You can use the BG color attribute in the body section to specify the HTML color tag. Simply define the BG color under the relevant tag, and you can easily specify a color.
Hexadecimal color codes, popularly known as hex codes, are a method for defining color values in HTML. These hex codes work in pairs to define the characters or attributes of a specific color using the specific specification system #rrggbb.
To apply colors to HTML elements, you can define the color values using either RGB, HSL, or hex codes. Under the body of the coding, just specify the color codes according to the color you want to choose.
In HTML, there is no default color that is predefined by the application. However, your browser or operating system may have a default color that may appear while you work on HTML.
To apply a desired color to the text in HTML, you just need to use the font color tag under the body of the coding section.
Author
Talk to our experts. We are available 7 days a week, 9 AM to 12 AM (midnight)
Indian Nationals
1800 210 2020
Foreign Nationals
+918045604032
1.The above statistics depend on various factors and individual results may vary. Past performance is no guarantee of future results.
2.The student assumes full responsibility for all expenses associated with visas, travel, & related costs. upGrad does not provide any a.