CSS Types:

You can add styles in HTML page with three different types

  • Inline CSS
  • Internal CSS
  • External CSS

Inline CSS:

Inline CSS means we add styles to a single tag and it will apply only on that relevant tag. Use this type of style when you want to give some special style to that particular tag.

The drawback of Inline CSS is that you have to apply same styles on HTML elements repeatedly.

Example:

Internal CSS:

Internal CSS is used when you want to apply some common styles for HTML page. For this you have to use “<style>” the opening tag and “</style>” the closing tag. Between these tag you can write one or more styles for that relevant page. One thing you should know that always write the <style> and </style> tag in head.

Example:

External CSS:

External CSS means making a different CSS file which have .css extension. Always make an external CSS. But why? Because in any website there are so many web pages and they have some common properties so with Inline and Internal CSS you have to apply all properties in each and every page if there are 100 pages in any website then it will be very difficult to do that. So this time External CSS is very useful. If you want to change or modify any style than you have to only make changes in that particular CSS and it will apply to all pages.

Example:

First we are making our style sheet with name style.css

Now in our HTML page we will link this style.css file in head section with the help of “link” tag and to use that property you have to write “class” keyword in that particular tag. Also note that your CSS file and HTML file should be in same place.

 

Leave a Reply

Your email address will not be published. Required fields are marked *