Question:

How do I use a CSS with an HTML document?

by  |  earlier

0 LIKES UnLike

I just made a CSS document and an HTML document with the help of an HTML tutorial website. I plan on using them together but none of the sites I browsed tell me how to connect the CSS to the HTML document. So how do I do this?

 Tags:

   Report

3 ANSWERS


  1. You need to link the CSS in your HTML document...in the <head> tag....like this...

    <link href="location of your css sheet" rel="stylesheet" type="text/css"/>

    The location is the relative link to the css sheet. Usually, it'd be something like this: "stylesheet.css"


  2. First, link the stylesheet in the HEAD of the HTML document. See the first link. Then, to apply the style to a piece of text, you can use a DIV, SPAN, or P tag with the style property applied via a "class" declaration. For example,

    <P class="classname">text</P>

  3. There are two ways to do this. Both need to go into the <head> tag.

    The first (more common way)

    <head>

    <link rel="stylesheet" type="text/css"

    href="stylesheet.css" />

    </head>

    The second way:

    <head>

    <style type="text/css">

    @import "stylesheet.css";

    </style>

    </head>

    It is incredibly important that you make sure that your path is correct as well. If your stylesheets lie in a separate folder from the index, you need to link them correctly.

    Lets say you have a separate folder named 'stylesheets'. You would need to link this way:

    <head>

    <link rel="stylesheet" type="text/css"

    href="stylesheets/stylesheet.css" />

    </head>

    Also, make sure that you place '.css' at the end of the file name. If you do not, the browser will not properly link to the stylesheet.  

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions