Book Image

Practical Web Development

By : Paul Wellens
Book Image

Practical Web Development

By: Paul Wellens

Overview of this book

Table of Contents (23 chapters)
Practical Web Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
10
XML and JSON
Index

Adding styles to our documents


So how do the CSS rules become part of our document? There are three ways:

  • External style sheets

  • Internal CSS

  • Inline styles

External style sheets

This is the recommended way to add CSS to your site. It should be your goal for all style sheets of the production version of your site to be external. Simply add a line to the <head> section of your site, which should look like the following:

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

<link> is an HTML element we had not yet introduced. Its attributes are listed below:

  • rel, to indicate the relationship between the HTML document and the linked file.

  • type specifies the MIME type of the document so the browser knows how to load it.

  • href is used to specify the location of the file. You may expect a src attribute here, like is used for <img> tags, but the attribute to specify the file name in a <link> element is href. For the file name, we recommend that you always use relative...