Types of CSS

CSS (Cascading Style Sheet) describes the HTML elements which are displayed on screen, paper, or in other media. It saves a lot of time. It controls the layout of multiple web pages at one time. It sets the font-size, font-family, color, background color on the page.

It allows us to add effects or animations to the website. We use CSS to display animations like buttons, effects, loaders or spinners, and also animated backgrounds.

Without using CSS, the website will not look attractive. There are 3 types of CSS which are below:

  • Inline CSS
  • Internal/ Embedded CSS
  • External CSS
Types of CSS

1. Internal CSS

The Internal CSS has

After adding the internal CSS, the complete HTML file looks like the following:

We can also use the selectors (class and ID) in the style sheet.

Example:

Pros of Internal CSS

Cons of Internal CSS:

2. External CSS

In external CSS, we link the web pages to the external .css file. It is created by text editor. The CSS is more efficient method for styling a website. By editing the .css file, we can change the whole site at once.

To use the external CSS, follow the steps, given below:

1. Create a new .css file with text editor, and add Cascading Style Sheet rules too.

For example:

2. Add a reference to the external .cssfile right after