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.

Tag: LINK
Attribute: REL
Value: stylesheet

Tag: LINK
Attribute: TYPE
Value: text/css

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

Example:

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

Example (in context):

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

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