DEV Community

Cover image for My Journey Learning CSS - Fonts, Text and Color Properties πŸš€ (Day-9)
Angshuman
Angshuman

Posted on

My Journey Learning CSS - Fonts, Text and Color Properties πŸš€ (Day-9)

Whether you're a beginner or looking to refine your skills, understanding font properties, spacing, and styling is essential. In this post, we’ll explore the fundamentals of typography in web development and how to implement them in HTML and CSS.

Understanding Font Properties πŸ“Š

Fonts shape the visual appeal of a website and impact how users perceive content. Here are some key font properties:

. Font Family

The font-family property defines the typeface used on a webpage. It’s always a good practice to include multiple font choices as fallbacks in case a browser doesn't support a specific font.

. Font Size

Font size determines how large or small the text appears. Common units include:

px (pixels) – fixed size.

em – relative to the parent element.

rem – relative to the root element.

% – percentage of the parent element's font size.

. Font Weight

The font-weight property controls how bold or light the text appears. It accepts predefined values like normal, bold, lighter, or numeric values from 100 (thin) to 900 (extra bold).

. Line Height

The line-height property adjusts the space between lines of text, improving readability.

. Letter Spacing

Letter spacing determines the space between characters in a word.

Importing and Applying Fonts πŸ“Š

Using custom fonts enhances the uniqueness of your website. One of the easiest ways to import fonts is through Google Fonts.

Importing Fonts via Google Fonts

Visit Google Fonts.

Select a font and copy the provided <link> tag.

Paste it inside the <head> section of your HTML file.

Image description

Text Decoration and Colors πŸ“Š

Enhancing text styling makes content visually appealing. Here are some common properties:

. Text Decoration

The text-decoration property controls underlining, overlining, and strikethrough effects.

Example:

Image description

. Text Color

The color property sets the font color using named colors, hexadecimal (#000000), RGB (rgb(0,0,0)), or HSL values.

Example:

Image description

Conclusion 🎯

Mastering typography is essential for creating visually appealing and readable web pages. By understanding font properties, spacing, and styling, you can significantly enhance your website’s design. Experiment with different fonts and styles to find what works best for your project!

Top comments (0)