Thursday, May 10, 2007

Inserting styles

We can insert styles with html elements in three ways.

Define the styles in an external stylesheet and associate the stylesheet with the html page like this. (This is the preffered way of defining stylesheets)

<head>
<link rel="stylesheet" type="text/css" href="images/adaptive-stylesheet.css" >
</head>

Define the style in the html page like this. (We would usually do this only if we want to associate a style with a particular web page)

<head>
<style type="text/css">
p
{
color: blue
}
</style>
</head>

Define it in the element like this. (This is the least preffered way, which is used only if we want to associate the style with a particular element)

<p style="margin-left: 20px; color: red">

No comments: