External Style Sheet

With an external style sheet, you can change the look of an entire website by changing just one file! Inside the <link> element of each HTML page, include a reference (HREF) to the external style sheet file, as well as a definition of the relationship (REL) to the link and -- well, TYPE is self-explanatory. The <link> element goes inside the head section:

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

An external style sheet can be written in any text editor. The file should not contain any html tags. The style sheet file must be saved with a .css extension. Here is an idea of how a style sheet file, called "myStyle.css," might look like:

body {
   background-color: lightblue;
}
h1 {
   color: navy;
    margin-left: 20px;
}
Good habit Do not add a space between the property value and the unit (such as margin-left: 20 px;). The correct way is: margin-left: 20px;
Back button Table of Contents Next button