Surf 11 » Using CSS in HTML HEAD

Finding the best waves on the web.

There are two ways you can add a CSS stylesheet into the head of your HTML or XHTML document. The first way is to use the style tag:

<html>
<head>
 <style type="text/css">
 body { font-family: verdana, arial; }
 </style>
</head>
...

The second way to insert CSS into your HTML document in the HEAD section is by using the link tag, for example:

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

In the first method we are writing the CSS directly in the HTML or XHTML document, in the second example we are linking to a single file called style.css. Most people prefer the second method because it allows you to keep all your CSS code in one file, rather than scattered throughout many files. If you want to change a color or font, you only have to edit one file.



Related Entries
Name:

Email: (optional, not displayed on site)
   Subscribe to this thread
Comments: (html will be escaped)



Subscribe to our RSS Feed: subscribe to this feed XML
Archives   Tags   Contact