CSS text styling | style text with CSS – codewithrandom

  styling css text | css text styles

Hey friends, today I’ll teach how to style HTML text using CSS! Btw, I’m CodingPorium and I make coding tutorials and provide Free Source Code on YouTube and Instagram.


We use text in HTML to convey messages, tell about yourself, and literally many more. Without text, your website will definitely look dull unless you want to use your website to show any photos, etc.
Generally, the text on your HTML site is black in color in default. However, with the power of CSS, we can configure it to make it much more beautiful.

Element or Class?

We can style text using CSS but we need to decide what to use. Do you want to style by using the HTML tag as the selector or give a class or id for your text and then style it?
In today’s demo, to make things simple, I will be using the HTML tag itself to style as the selector. Let’s move on.

Basic Code

For your to easily follow along in this tutorial, paste the following code block in your HTML file:

Okay, now let’s move on to styling it.

css text Color Change

we can first try changing the color of the text. This is possible by using the CSS color property. We will change its color to a red color. Look at the code block below for a better understanding.

css text Background Color

Now let’s add some background color for a nice highlight effect or just for design. we will use the background-color property for this. Look at the code block below for more:


Javascript project ideas with complete source code 

css text Underline Effect

Now we will make an underline effect for the HTML text. We can do this by using the <u> tag in HTML, but let’s learn how to do it in CSS to be more professional.
Check out the code block below:

You can do a lot more!

These were just some basic examples. With the power of CSS through properties like padding, center text-align, etc you can style your text to look even more awesome. Below I’m going to show a code block example where I’ve added several more CSS properties.

And that’s all for this post. I hope this post can help you learn how to style text using CSS easily. As you learn CSS properties, you can upgrade this all even more. Thanks and goodbye!

written by @codingporium

Thanks for reading! Do contact me via the methods below if you have to say anything:

Share on:

Leave a Comment