📘 DAY 11: HTML COLORS
1️⃣ What are HTML Colors?
HTML Colors are used to:
Set text color
Set background color
Style borders and elements
Colors are applied using CSS properties, mostly through the style attribute in HTML.
2️⃣ Applying Color in HTML
Colors are usually applied using:
Example:
3️⃣ Types of Color Values in HTML
HTML supports four main types of color values:
Color Names
HEX Values
RGB Values
RGBA Values
4️⃣ HTML Color Names
HTML supports predefined color names.
Examples:
👉 Easy to use, but limited choices
5️⃣ HEX Color Values
HEX values represent colors using hexadecimal numbers.
Format:
Example:
✔ Most commonly used
✔ More control over colors
6️⃣ RGB Color Values
RGB stands for Red, Green, Blue.
Format:
Example:
👉 Values range from 0 to 255
7️⃣ RGBA Color Values
RGBA is RGB with Alpha (opacity).
Format:
Example:
✔ Alpha value ranges from 0 to 1
8️⃣ Background Colors
Background color is applied using:
Example:
9️⃣ Text and Background Together
🔟 Border Colors
1️⃣1️⃣ Common Color Codes (Useful)
| Color | HEX |
|---|---|
| Black | #000000 |
| White | #ffffff |
| Red | #ff0000 |
| Green | #00ff00 |
| Blue | #0000ff |
| Gray | #808080 |
1️⃣2️⃣ Color Accessibility (Important)
✔ Use high contrast colors
✔ Avoid light text on light background
✔ Improves readability and accessibility
1️⃣3️⃣ Common Beginner Mistakes
❌ Forgetting # in HEX
❌ Using invalid color names
❌ Poor contrast combinations
❌ Overusing colors
1️⃣4️⃣ Practice Examples
Example 1:
Example 2:
1️⃣5️⃣ Interview / Viva Questions
What are HTML colors?
Types of color values in HTML?
Difference between RGB and RGBA?
What is HEX color code?
What is alpha value?
1️⃣6️⃣ Summary
Colors style HTML elements
Use
colorandbackground-colorHEX and RGB are most common
RGBA supports transparency
Use colors carefully for readability
0 comments:
Post a Comment