• Keyboard Shortcuts

    Shortcut keys help provide an easier and quicker method of navigating and executing commands in the computer software.

  • Hardware Tips

    Learn about the latest computer hardware and find out how to diagnose

  • Knowledge Practise questions and answers

    Here you can practise more questions and answers to improve your knowledge on computer

Thursday 3 August 2017

Computer Education - Changing the font type, size, and color displayed on a web page

Changing the font type, size, and color displayed on a web page

This page is related to changing font type, size, and color on a web page. For Microsoft Word, see our page on how to change the font color, size, or type in Word.


This document contains instructions on how to change a font and its color on a web page. The proper syntax moving forward is to use Cascading Style Sheets along with the class or ID selectors rather than an inline style attribute or font tag, which are deprecated. Although, it is worth noting that these two methods still work with most Internet browsers.


To proceed, select the method you would like to learn from or read every section.

  • Using CSS for a single application
  • Using CSS for one or more pages
  • The Font tag
 Using CSS for a single application

If you plan on changing the font face and its color only once on a web page, you need to change its attributes within the element tag. Using the style attribute, you may specify the font face and color with font-family, color, and the font size with font-size, as shown in the example below.

 


Result:
This text has the Courier font, is Blue, and 20px in size.
Using CSS for one or more pages

Custom font for one page
In the head portion of your web page, you may insert code between the <style></style> tabs to change the appearance of your text in various elements. The next blue box contains example code that, once called, would change your font face to Courier and color it red. As you can see, we have defined the class name as "custom."





 Once defined, this styling can be applied to most elements in your page by attaching the class "custom" to them. The following box shows two lines of code and their respective results.
Example:



Result:
This whole sentence is red and Courier
Only the word TEST is red and Courier.


Custom font for many pages



Importing an external CSS file can be very beneficial in that it allows users to change rules for multiple pages at the same time. The following section shows an example for creating a basic CSS file that changes the font and it's color for most elements. This file may be loaded into more than one web page, even an entire site.

Using any basic text editor, saving the following text as a .css file will prepare it for import.
 


Once the preceding text has been placed into a .css file (we have named ours basic.css), you can link to it from any other page using a line similar to the following example.


Users may change the attributes of elements on a page by changing the code within the imported .css file.

Font tag solution

Although deprecated, the HTML <font> tag can still be used and may be necessary to be used with some online services. When using the FONT tag, you must include the face attribute, which describes the font to be used. In the example below, we are using the Courier font and the hexadecimal color code #005CB9, which is a dark blue.
Example:


Result:
A special font example.


Good Morning Beautiful

Do you know????

Do you know????
/