Linked Style Sheets

An external CSS document is attached to an HTML page using the LINK tag. The LINK tag, like IMG and BR, doesn't ordinarily close, so you must use the "space-close-slash" before the closing bracket syntax we've used before.

Example (abbreviated):

<link />

The LINK tag always goes in the HEAD of an HTML page. LINK requires three attributes: REL, TYPE, and HREF.

Attribute: REL
Value: stylesheet

Attribute: TYPE
Value: text/css

Attribute: HREF
Value: any URL, relative or absolute, to the external CSS document that you want to link to the HTML page.


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

Example (in context):

<title>My Test Page</title>
<link rel="stylesheet" type="text/css" href="./myStyles.css" />
<p>Some text...</p>

Note: Despite the fact that, at this time, the LINK tag is only used to attach external CSS documents to an HTML page, the REL, and TYPE attributes of the LINK tag are there to tell the web browser that this particular LINK tag is REALLY a CSS LINK tag. These attributes allow the LINK tag to be expanded, one day, to work with some other technology. In the meantime, however, REL and TYPE will always be the values indicated above.

Main Menu