What can I do to change the HTML Font Color

Apr 6, 2022

The above code will alter the color of every paragraph on the webpage to purple. Like the inline CSS method, you are able to use different selectors to change the font color of your headers and links.

If you want to use the Hex Code, here's the way the code will look like:


 
 
 
 <p> 
 color: #800080;
 
 
 

This example uses RBGA values so you can look at an example of how to set the opacity:


 
 
 
 
 
 
 
 <p> 
 
 color: RGB(153,0,255,0.75),
 
 
 
 
 
 

and the HSL code could look something similar to this:


 
 
 
 <p> 
 color: hsl(276, 100%, 50%),
 
 
 

External CSS

This stylesheet is responsible for all styles used on your site and specifies the colors of fonts and font sizes, margins as well as paddings. It also specifies font families, font family names, background colors, and much more. In short, it determines how your website appears visually.

To alter the font's color by using external CSS it is necessary to use the selectors to style the parts of HTML you'd like to change. For example, this code alters all text of your site.

body color: purple

Internal, inline, embedded External, Inline

Now you are aware of how you can make use of CSS to change the font color. But which method should you choose?

If you're using within-line CSS code, you'll add directly to your HTML document. In general, this approach is suitable for quick corrections. If you'd like to alter the colour of a particular sentence or heading of a page, this technique is the fastest and the most simple method to accomplish it.

However, inline styles can make the size of your HTML document larger. The larger your HTML file more large, the longer it'll take for your webpage to load. Furthermore, inline CSS can make your HTML dirty. Therefore, the inline technique to use CSS to change the HTML font's colors is typically not recommended.

Embedded CSS is placed between the

tags as well as within the style> tags. Like inline CSS, it's good for quick fixes or overriding the styles defined within an external stylesheet.

The main difference between embedded and embedded styles is the fact that they can be applied to all pages that head tags are loaded onto Inline styles are applicable only to the particular page they're on, typically the element they're targeting on that page.

The third method, known as external CSS makes use of a separate stylesheet that defines the style you want to use for your images. In general, it is recommended to make use of an external stylesheet in order to maintain all of your style preferences together and make them easy to edit. It also helps to separate presentation from style, which means that the code is simple to handle and update.

Be aware that embedded and inline styles can override styles set in the external stylesheet.

Font Tags or CSS Styles: Benefits and Pros and

Two primary ways of changing the HTML font's colors is to make use of the font tag, or CSS styles. Both of these methods have advantages and disadvantages.

HTML Font Tags Pros And Cons

The HTML font tag is simple to use, so that's a pro in its favor. Typically speaking, CSS is more complicated and requires more time to master as opposed to typing . If you've got an older website that isn't using HTML5 or CSS, using the font tag could be an effective method to change the color of your font.

Although it is simple to use, you shouldn't apply it to your site that uses HTML. The font tag was dropped in HTML5. Utilizing code that is no longer supported should be avoided as browsers could discontinue support for the font tag at any point. This could lead to your website breaking and not functioning correctly or, even worse, rendering inaccessible to the visitors.

CSS Pros and Cons

CSS as well as the font tag, comes with both pros and cons. The most significant advantage that comes with making use of CSS is that it's the proper method of changing the color of fonts and also specify other styles you want to use on your website.

It distinguishes design from presentation, which helps your code to maintain and manage.

On the downside, CSS and HTML5 may take time to learn and write effectively when compared with the older method of writing codes.

Keep in mind that with CSS it is possible to choose different methods of altering the font's color. Each one of them has its own set of pros and cons, which we have discussed in the past.

Tips for Changing HTML Font Color

Now that you know how to alter the HTML font's color, here are a few tips that will aid you in your quest.

Use A Color Picker

Color pickers streamline the color selection process.
Color pickers simplify the color selection process.

Instead of picking colors randomly instead, make use of color pickers to select the right hues. The benefit of a color picker is that it can give the name of the color and the right hex, RGB, and HSL values that you need to include in your code.

Make sure you check the contrast

Use a contrast checker to test various text-to-background color contrast ratios.
Use a contrast checker to test various text-to-background color contrast ratios.

Text with dark backgrounds and light text with light background isn't a good match. It makes the texts on your site difficult to read. But, you could employ the contrast checker to ensure your site's colors are accessible and the text is easy to comprehend.

Find the Color Using the Inspect Method

Using Inspect to find color codes.
Utilizing Inspect to locate colors.

Summary

Changing the HTML font color can help improve your website's readability as well as accessibility. It also helps you establish brand consistency in your style of your website.

In this article, you've learned about the four ways you can alter the HTML font color: with color names, hex codes, RGB, and HSL values.

Also, we've covered the ways you can change the color of the font with embedded, inline, or external CSS and the font tag, as well as the pros and cons of each method. By now, you should be aware of what method you can use to change the HTML font's color. So, all you have to do now is to implement these tips on your website.

What are your thoughts on altering the color of fonts using CSS or font tags? Let us know via the comment section!

Reduce time, money and improve site performance by:

  • 24/7 help and support from WordPress hosting specialists, 24 hours a day.
  • Cloudflare Enterprise integration.
  • The global reach of the audience is enhanced by 29 data centers across the globe.
  • Optimization using our built-in Application for Performance Monitoring.