• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

11. Managing Style Sheets > 11.4. Importing External Style Sheets

Importing External Style Sheets

NN 4, IE 4

Problem

You want to implement a style sheet strategy across multiple HTML documents in a web site without embedding explicit CSS code in every document.

Solution

Define a style sheet (with one or more rules) as a separate .css file and import it into a document with the <link> tag:

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

The contents of the style sheet file should consist solely of style sheet rules. Do not include the <style> tags or the usual nested HTML comments in this file.

Discussion

The Solution shows a cross-browser solution that works with all CSS-capable browsers. More current browsers that support the CSS2 specification can use an alternative “at-rule” inside the document’s <style> tags. The at-rule version of the Solution is:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint