Tailwind CSS / Typography and Text Utilities

Applying Text Colors and Decorations

In this tutorial, we will explore how to apply colors and decorations to the text on your webpage. You will learn to use these features to emphasize and differentiate your content.

Tutorial 4 of 5 5 resources in this section

Section overview

5 resources

Explains how to use Tailwind's typography utilities for styling text.

Tutorial: Applying Text Colors and Decorations

1. Introduction

In this tutorial, our goal is to understand and apply colors and decorations to the text on your webpage. These features help to emphasize and differentiate your content, thereby enhancing the user experience.

By the end of this tutorial, you will learn:

  • How to change the color of your text.
  • How to apply decorations like underline, overline, and strikethrough to your text.

Prerequisites:

  • A basic understanding of HTML
  • A basic understanding of CSS

2. Step-by-Step Guide

Text Color

In CSS, the color property is used to define the color of the text.

Here is an example:

<p style="color:blue;">This is a blue text.</p>

Text Decoration

In CSS, the text-decoration property is used to add decorations to text. It has four values:

  • none: Produces no text decoration.
  • underline: Underlines the text.
  • overline: Places a line above the text.
  • line-through: Strikes a line through the text.

Here is an example:

<p style="text-decoration:underline;">This is an underlined text.</p>

3. Code Examples

Let's look at some practical examples.

Example 1: Changing text color

<!-- The color of the paragraph text is red -->
<p style="color:red;">This is a red text.</p>

In this example, the color property is used to change the text color to red.

Example 2: Applying text decorations

<!-- The paragraph text is underlined -->
<p style="text-decoration:underline;">This is an underlined text.</p>

<!-- The paragraph text is struck through -->
<p style="text-decoration:line-through;">This is a strikethrough text.</p>

In the first paragraph, the text-decoration property is set to underline, which underlines the text. In the second paragraph, it is set to line-through which strikes a line through the text.

4. Summary

In this tutorial, we have covered how to change the color of your text and how to apply different text decorations like underline, overline, and strikethrough using CSS.

To further enhance your skills, you can:

  • Experiment with different color and text decoration combinations.
  • Learn about other CSS properties that can help you style your text.

You can find more information on these topics at Mozilla Developer Network.

5. Practice Exercises

Now, it's time to practice what you've learned.

Exercise 1: Create a paragraph with green text.

Solution:

<p style="color:green;">This is a green text.</p>

Exercise 2: Create a paragraph with blue text and an overline.

Solution:

<p style="color:blue; text-decoration:overline;">This is a blue overlined text.</p>

Exercise 3: Create a paragraph with red text and a strikethrough.

Solution:

<p style="color:red; text-decoration:line-through;">This is a red strikethrough text.</p>

Keep practicing and experimenting with different combinations to get a better understanding of how text colors and decorations work in CSS.

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

CSS Minifier & Formatter

Clean and compress CSS files.

Use tool

Meta Tag Analyzer

Analyze and generate meta tags for SEO.

Use tool

Watermark Generator

Add watermarks to images easily.

Use tool

Random Number Generator

Generate random numbers between specified ranges.

Use tool

Image Compressor

Reduce image file sizes while maintaining quality.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help