3 ways to add CSS to your web sites

CSS to half of a character

Website can not be completed without any style. So you apply CSS. When a browser reads a CSS style sheet, this formats the HTML document according to the information in the CSS style sheet.

With 3 basic ways you can add CSS in your web pages:-

1) Link your webpage with an external file:

<link href="style.css" rel="stylesheet" type="text/css">

or import CSS:

 <style type="text/css" media="all">
 @import "../style.css";
 </style>

Read Also: Align text vertically next to an image

2) Put the css between the <head> tags:

 <!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 <title>Sample page</title>
 <style type="text/css">
 div { padding-top: 10px; }
 </style>
 </head>
 <body>
 </body>
 </html>

3) add CSS using inline:

 <div style="padding-top:10px;">Your content goes here...</div>
You may like:  Difference between @import and link

One thought on “3 ways to add CSS to your web sites”

Leave a Reply

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