Welcome to this tutorial on how to change text color in HTML. Changing the color of your text can make your website more visually appealing and improve readability. We’ll cover three main methods: inline CSS, internal CSS, and external CSS. Let’s dive in!
Inline CSS allows you to apply styles directly to a specific HTML element. Here’s how you can change the text color using inline CSS:
<p style="color:blue;">This is a blue text.</p>
In the above example, the text within the paragraph tag (<p>) will appear blue.
Internal CSS involves adding a <style> tag within the <head> section of your HTML document. This method is useful when you want to apply a style to multiple elements on a single page. Here’s an example:
<p>This is a red text.</p>
In this example, all paragraph text on the page will be red.
External CSS involves creating a separate .css file and linking it to your HTML document. This method is ideal for larger projects where you want to apply consistent styles across multiple pages. Here’s how you can do it:
/* In your .css file */
/* In your .html file */
<link rel="stylesheet" type="text/css" href="styles.css">
<p>This is a green text.</p>
In this example, all paragraph text across all pages linked to the styles.css file will be green.
And that’s it! You now know how to change text color in HTML using inline CSS, internal CSS, and external CSS. Remember, a well-designed website is not just about looks, but also about readability and user experience. So, use colors wisely!