Introduction

Before moving on with this session, I would strongly recommend you to check Part 1 of this series.
The following are the topics that we will discuss in this article.
  1. Background properties
  2. Text properties
  3. Font properties
  4. Link properties
Background properties
To define or add a background, we can use the background properties.
Text Properties
To change the fore-color of a paragraph we use the color property that is nothing but a text property. Using the text property we can decorate the text using the Text-Decoration property or we can change the alignment of the text using the Text-Align property and many more.
Let's look at each of them.
Font Properties
The font properties can be classified into the following:
  1. Font-family
  2. Font-size
  3. Font-style
  4. Font-variant
  5. Font-weight
  6. Font
Let's look at each of them practically.
Create a new HTML file and write the following inside the body element.
  1. <body>
  2. <p id="para1">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
  3. <br/>
  4. <br/>
  5. <p id ="para2">Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
  6. </body>
Note: The paragraph content is just a snippet provided by the sublime text editor.
Open the file in a browser.
In the same HTML file, create a new internal stylesheet in the head section and write the following in it.
  1. <head>
  2. <title></title>
  3. <style type="text/css">
  4. #para1{
  5. #para2{
  6. }
  7. </style>
  8. </head>
So, until now what we have done is, we have created a new HTML file in which we added two paragraphs with an id of para1 and para2 respectively.
In the head section of the same HTML file, we created an internal stylesheet in which we created two new CSS rules using an id selector.
Now let's say we want to change the font family of para1 to Verdana and font family of para2 to Garamond. For that, we can use the font-family property and pass the value as Verdana for para1 and pass the value as Garamond for para2.
  1. <style type="text/css">
  2. #para1{
  3. font-family: Verdana;
  4. }
  5. #para2{
  6. font-family: Garamond;
  7. }
  8. </style>
Currently, our HTML page looks like this.
Refresh the page.
So, now the font of the paragraphs is changed respectively.
Link Property
Whenever you want to add styles to hyperlinks then use the link properties.
There are four states of link:
  1. a:link: it is a normal state meaning the link is unvisited.
  2. a:visited: a visited link.
  3. a:hover: a state where the user hovers the mouse over the link.
  4. a:active: link that is clicked.
NOTE
a:hover must come after a:link and a:visited whereas a:active must come after a:hover.
Let's look at an example of it.
DEMO
Create a new HTML file and in the body section, add an anchor tag element.
  1. <body>
  2. <a href="http://www.c-sharpcorner.com/">CSharpCorner</a>
  3. </body>
Open the file in a browser.
In the head section of the same file, create an internal stylesheet.
In this stylesheet create the rules for all four states in the same order as shown below.
  1. <style type="text/css">
  2. a:link{
  3. }
  4. a:visited{
  5. }
  6. a:hover{
  7. }
  8. a:active{
  9. }
  10. </style>
Now let's say our business requirements are such that we don't want to display an underline in the link.
In the first statem a:link rule, write the following.
  1. a:link{
  2. /*To remove the underline, pass none in the text-decoration property*/
  3. text-decoration: none;
  4. }
Refresh the page.
Whenever a link is visited, we want to change the color from default to Black and for that pass the value Black in the color property in the visited state, in other words, a:visited.
  1. a:visited{
  2. color: black;
  3. }
Refresh the page and click on the link.
Now whenever a user hovers the mouse on the link, we want to change the color of the link from default to Yellow and pass the color property value as Yellow in the hover state of the link.
  1. a:hover{
  2. color: yellow;
  3. }
Refresh the page.
Now let's say that whenever the user clicks the link, meaning when the link is active, we want to change the background color of the link to Black and the text color to Red and for that, we can use the background-color and color property in the a:active state.
  1. a:active{
  2. color: red;
  3. background-color: black;
  4. }
Refresh the page.

Summary

This article explained the four most commonly used properties Background, Text, Font, and Link.
The next article of this series will explain more about properties.
Until then keep learning.
Thank you.