how many ways are there to add css in our html file.

hellow everyone.

Welcome to mr.advancetechnical.


how many ways are there to add css in  html file.

there are mainly 3 ways to add css in html file.

1.using internal css.
2.using external css.
3.using inline css.

1. using internal css:

we can add css in our html by using style tag inside head tag which called as internal CSS.

like.
<head>
<style type="text/css" rel="stylesheet">
p{
color:red;
}

</style>
</head>

here the text color of every p element will be red.
it can be override by inline css.

2. using external css:
we can add css in our html by Making separate css file which called as external CSS.

 like here we are making style.css(external css):-
style.css

p{
color:red;
}

to add this external css in our html file we have to use link tag inside our head tag.
like this.
demo.html 

<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>
good morning.
</p>
</body>

here our all p element's text will be in red color.
it can be override by internal and inline css.
the main Benifit of the external css is that we can use it in multiplw pages.
and also while making website it is preferable. because the site's perfomance becomes faster.  (once css file downloaded locally on the browser the all pages  loads faster ).

NOTE:-

  • external css dosen't contains any html tags.
  • the extension of external css file should be .css


3. using inline css:

by using inline css we can apply css on particular selected Elemnent.

like:

<body>
<p style="color:red">good morning</p>
</body>

to use inline css style attribute is used.

  • it  overrides both internal and external css.


so that's it for today.


thanks.

No comments: