Cascading Style Sheets
Attaching Style Sheets
-------------------------
For any style sheet to affect an HTML document, it must be attached. This can be done in several ways, depending on which kind of style sheet you're attaching. For inline CSS, you would add style rules using the inline method. For an internal style sheet, which is created within the HTML document, you can use the embed method. For an external style sheet, where you create a separate CSS file, there is the link and import methods.
<p style = " /* In the body of your HTML code, add the style attributes that CSS is defining to the HTML tag i.e. */ font-size:10pt; </p> /*Close the tag pair with the corresponding end tag.*/
|
<head> /* The code below opens a CSS style container within the head of your HTML document */ <style type="text/css"> <!-- Put your CSS Rules here, i.e. h1 { font-style: bold } --> </style> /*close the style definition by typing one end tag */ < /head> |
Linking an external file sheet to an HTML document. <head> /* Within the head of your HTML document, include this code. It tells the browser that a style sheet is being linked and it's of a certain type */ <link rel = "stylesheet" type="text/css" href=" cssFileLocation/URL/Filename.css" > /* In the place of "cssFileLocation/URL/Filename.css", specify the location, either global or local, of the CSS file to be used. Below are two examples.*/ /* local location */ /*global location*/
</head> Link as many style sheets as you like. |
To import a CSS document into an HTML document 1. Within the head of your HTML document, open a style container. <style type = "text/css">
/*global location*/
</style> |