-
Hajipur, Bihar, 844101
HTML colors are used to change the appearance of text, backgrounds, borders, and more. You can apply colors using the style
attribute with properties like:
color
(for text)
background-color
border-color
Color Names
Example: red
, blue
, green
, black
Hex Codes
Example: #FF0000
(red), #00FF00
(green)
RGB Values
Example: rgb(255, 0, 0)
(red)
RGBA Values
Example: rgba(0, 255, 0, 0.5)
— includes transparency
HSL Values
Example: hsl(240, 100%, 50%)
HSLA Values
Example: hsla(120, 100%, 50%, 0.3)
<p style="color: red;">This is red text.</p>
<p style="background-color: yellow;">Yellow background</p>
<p style="color: #00ff00;">This is green text.</p>
<p style="color: rgb(0, 0, 255);">Blue using RGB</p>
<p style="color: rgba(255, 0, 0, 0.5);">Red with transparency</p>
<p style="color: hsl(120, 100%, 25%);">Dark green with HSL</p>
<p style="color: hsla(240, 100%, 50%, 0.3);">Blue with transparency</p>
<h1 style="background-color: lightgray;">Heading with background</h1>
<div style="border: 2px solid blue; color: white; background-color: black;">
Colored box with text
</div>
Q1. Create a paragraph with text color set to blue using a color name.
Q2. Use a hex code to make text green.
Q3. Apply a yellow background to a heading.
Q4. Use rgb()
to display red text.
Q5. Display semi-transparent text using rgba()
.
Q6. Style a box with a background color and white text.
Q7. Use hsl()
to color a paragraph dark blue.
Q8. Create a button with a colored border using style
.
Q9. Add color to a table header using background-color.
Q10. Make a full section background orange and text black.
Q1: Which property is used to change text color in HTML?
Q2: Which of the following is a valid hex code for color?
Q3: What does RGBA stand for?
Q4: What value in RGBA controls transparency?
Q5: What does the color #000000 represent?
Q6: What is the maximum value for RGB components?
Q7: Which of these is a valid color name in HTML?
Q8: Which of the following will make text red?
Q9: What does the “L” stand for in HSL?
Q10: Which color model allows transparency control?