O'Reilly logo

Web Programming with HTML5, CSS, and JavaScript by Dean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.11 External CSS Files

Overview

In general, splitting up a big thing into smaller parts makes the thing easier to understand. To improve understandability, you should consider moving your CSS rules to an external file. There are two steps necessary to tie a web page to an external file that contains CSS rules. First, for the external file to be recognized as a CSS file, the external file must be named with a .css extension. For example, in an upcoming web page, we’ll use the filename pumpkinPatch.css. Second, for the web page to access a CSS file’s CSS rules, the web page must use a link element in the web page’s head container. The link element is a void element, so it’s comprised of just one tag, with no end tag. Here’s the syntax:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required