"I am Saqib Jahangir. A passionate vlogger, software engineer, and avid traveler with a deep love for exploring the hidden gems of our beautiful planet. With a strong foundation in Application Development, Application Architecture & Database Design and Product Management, I bring over a decade of hands-on experience building secure, scalable, and resilient web applications for a diverse range of industries."

Text and Font Styling in CSS

 

🎨 Text and Font Styling in CSS

CSS provides powerful tools to style text and fonts, allowing developers to control the appearance and readability of web content. Below are the most common properties used for styling text and fonts.


1. color

Defines the color of the text.

p {
  color: #333333;
}

2. font-family

Sets the typeface for the text.

p {
  font-family: Arial, Helvetica, sans-serif;
}

Tip: Always include fallback fonts in case the primary one isn’t available.


3. font-size

Controls the size of the text.

p {
  font-size: 16px;
}

Common Units:

·         px (pixels)

·         em (relative to parent)

·         rem (relative to root)

·         % (relative to parent)


4. font-weight

Defines the thickness of the text.

p {
  font-weight: bold;
}

Values:

·         normal

·         bold

·         lighter

·         Numeric: 100 to 900


5. font-style

Makes text italic or oblique.

p {
  font-style: italic;
}

6. text-align

Aligns the text inside its container.

p {
  text-align: center;
}

Values:

·         left

·         right

·         center

·         justify


7. text-decoration

Adds decoration to text like underline, line-through, etc.

a {
  text-decoration: none;
}

Values:

·         none

·         underline

·         line-through

·         overline


8. line-height

Sets the vertical spacing between lines of text.

p {
  line-height: 1.5;
}

9. letter-spacing

Controls space between characters.

p {
  letter-spacing: 1px;
}

10. text-transform

Changes the case of text.

h1 {
  text-transform: uppercase;
}

Values:

·         uppercase

·         lowercase

·         capitalize

 

Popular Posts

Setting Up Your First Project Folder and Installing XAMPP or WAMP

Frontend vs Backend vs Full Stack