CSS in HTML:

CSS is stands for Cascading Style Sheet. CSS is a very important part of HTML. CSS make pages presentable on screens and print. Style sheet is an add-on for HTML pages to make the attractive. We can also say that CSS is a style language that defines the layout of HTML pages.

With CSS we can can give colors to text, background color, margin, padding, width, height etc. which we learn in our tutorial.

Example:

Types of CSS:

In HTML CSS have 3 types of styles:

  • 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.

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 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.

Note:

There are two ways to make styles first by “.” and by “#”. When you create a style using “.” then call it in HTML page by “class” and when you create a style using “#” then call it by “id”. The properties in ID will be important than class.

Example:

In following example we use both type of style declaration:

The HTML is as follows:

 

 

3 responses to “CSS in HTML”

  1. Angelica says:

    I read a lot of interesting content here.

  2. Brenda says:

    You share interesting things here. Thanx and keep doing it.

  3. Rechal Joe says:

    Good day- I am so happy I found your site. I’m really admiring the time and energy you put into your site and in depth information you present. It has been wonderfully open-handed of you to offer publicly what numerous people could have offered for an e-book to end up making some profit for themselves.

Leave a Reply

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