Header Ads

CSS Text Color Explained with Syntax and HTML Examples

 What Is CSS Text Color

CSS Text Color Explained with Syntax and HTML Examples

This Blog You Will Learn

 à®ƒ  What Is CSS Text Color
 à®ƒ  Syntax 
 à®ƒ  Purpose of Text Color
 à®ƒ  Real world Use Cases
 à®ƒ  What Is CSS Text Color Example 
 à®ƒ  Output


What Is CSS Text Color

CSS text color refers to the color applied to text content on a web page using the color property in CSS. It controls how text appears visually and plays a major role in readability, accessibility, branding, and user experience.

Syntax 


selector{
  color:value;
}

Purpose of Text Color

Make content readable. 
Highlight important information.
Match brand identity.
Create visual hierarchy.
Improve user experience.

Real world Use Cases
  1. Highlighting error messages.
  2. Emphasizing headings.
  3. Branding and theme design
  4. improving content readability.
ஃ structure diagram examples

CSS Text Color Explained with Syntax and HTML Examples



What Is CSS Text Color

Example 

<!DOCTYPE html>
<html>
<head>
<style>
body {
  color: black;
}

h1 {
  color: purple;
}

h2 {
  color: orange;
}
</style>
</head>
<body>

<h1>CSS Text Color</h1>
<h2>What Is CSS Text Color?</h2>
<p>CSS text color is used to control the color of text displayed on
a web page</p>
<p>It is defined using the color property in CSS.</p>
<p>This property helps improve readability, design consistency,
and visual appeal of a website. </p>

</body>
</html>

What Is CSS Text Color

Explain Program

Step  1] 

<!DOCTYPE html>

  • This declare the document type.
  • browser that the document is written in html

Step 2 ]

<html>.... . </html>

  • html is the root element of the html page.
  •  Every thing inside it is part of the webpage.

Step 3]

<head>

  • <head> section  contains metadata and css styles,not visible content.

  • Contains styles, metadata and page setting 

Step 4] <style> tag Internal CSS

  • Use to css directly inside the HTML file.
  • Controls appearance of elements on the page.
<style>
body {
  color: black;
}

  • set the default text of entire page to black.
  • Applies to text unless overridden by more specific selectors.


h1 {
  color: purple;
}

  • Change the color <h1> tag text color purple.
  • use for main headings.

h2 {
  color: orange;
}

  • Change the color of <h2> text  color orange.
  • use for sub-headings.

</style>
</head>

  • Closing Tag 

Step 5] Body Section

<body>

<h1>CSS Text Color</h1>
<h2>What Is CSS Text Color?</h2>
<p>CSS text color is used to control the
color o
  f text displayed on a web page</p>
<p>It is defined using the color property
in CSS.
  </p>
  <p>This property helps improve readability,
design consistency,
and visual appeal of a website.</p>

1)  <body>  

  • Contains all visible content shown on the webpage.
2)  <h1>      
  •  Displayed in purple. 
  • Style by h1 CSS rule.
3)  <h2>    
  • Displayed  color orange.
  • Styled by h2 css rule.
4) <p>      
  • Displayed in black.
  • inherits color from body selector.  
Step 6]

   Closing tag
</body>
</html>

What Is CSS Text Color
Output

What Is CSS Text Color


Related Post :-



No comments

Powered by Blogger.