Style Sheets

External style sheets

<head>
<link rel="stylesheet" type="text/css" href="file-name.css" [media="<screen, print, ...>*"]>
</head>
<head>
<style type="text/css" [media="<screen,print,...>*"]>
@import url(file-name.css);
@import url(file-name2.css);
</style>
</head>

Internal style sheets

<head>
<style type="text/css" [media="<screen, print, ...>*"]>
<!--

...

-->
</style>
</head>
  • Embedded style sheets
  • Optionally enclose the CSS code in HTML comments to prevent the rules from being displayed on the screen in older browsers (this is no longer essential)

Inline styles

<element style="property: value" ... >
Examples
<div style="padding: 5px 0px 2px 0px">

Importing a style sheet

@import url(/path/filename.css);
  • Can be used inside a CSS file or inside a <style> element
  • All import statements must occur at the beginning of the style sheet

Misc

  • An internal style sheet is appropriate when a single document has a unique style.