CSS Tutorial 4

Prepared by: Anthony Larrain


Document Level Styles

Example

<head> <title>Example Style</title> <style> body{ font-family:Verdana; } h1{ color:lawngreen; } </style> </head> <body> : :

External Styles

Example 1

Suppose we had a text file named style.css that contained the styles.

body{ font-family:Verdana; } h1{ color:lawngreen; }

To use these styles we need to link this file to the HTML document.

<head> <title>Linking to an external CSS file</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head>

Example

The HTML   The External Style Sheet


Inline Styles

Add the style to the element's start tag using the HTML style attribute.

Example

<p style="color:magenta;">This paragraph will be magenta</p> <p style="color:#3366FF;">This paragraph will be whatever 3366FF represents.</p>

Browser Display

This paragraph will be magenta

This paragraph will be whatever 3366FF represents.

@Anthony Larrain 2005 - 2006

Send Questions or Comments to hci201@yahoo.com