Insert CSS

Now we will have a look how to apply style to HTML page. There are three ways to write CSS style.

1 . Inline CSS:

It is written in the HTML tag itself using the word style and then defining property of the style.
for e.g. <span style”font-weight:bold; color:#ffffff;”>This is an Inline style of CSS</span>

2. Internal Style Style:
In internal CSS we define the style in the head of the HTML page. for e.g.
<head>
<style type=”text/css”>
hr {color:sienna}
p {margin-left:20px}
body {background-image:url(“images/back40.gif”)}
</style>
</head>

3. External CSS
In external CSS we have to an file with the extension .css which is than link to the HTML page.This is the ideal way of writting css style below mentioed is the tag to add the css file to the HTML page.
<head>
<link rel=”stylesheet” type=”text/css” href=”mystyle.css” />
</head>

We can add unlimted number of css file to a HTML page if needed, but idealy we just at 2 or 3 css file to a HTML. We can have difference css for print and also differece css for old browser like IE6.

So this are the basic way of writing CSS.

  • Share/Bookmark