Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How do I link my HTML doc to a CSS file?

Rather than have all my CSS in the HTML doc, I know you can link to if as a separate file but I don't know what the correct syntax is! I've been scouring W3 tutorials and they don't seem to mention how to do it!

Many thanks,

Ben

6 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    Put this between the head tags of every page you have that is styles with the CSS:

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

    DO NOT USE UPPERCASE for tag and attribute names.

    Ron

  • 1 decade ago

    Im between the head tags on all of the pages which you want to apply the stylesheet put:

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

    This links the webpage to the style.css file.

    A tutorial on a basic setup of a website can be found here, http://www.webdesignerhelp.co.uk/index.php/2008/08...

  • 1 decade ago

    HTML's link tag is one way to go, but css also includes a way to add external style sheets with the @import directive. You add the directive inside the HTML <style> tag:

    <style type="text/css">

    @import url(css/main.css);

    </style>

    Linking multiple external style sheets:

    <style type="text/css">

    @import url(css/main.css);

    @import url(css/game.css);

    </style>

    You can also create an external CSS file that contains only @import directives linking to other external style sheets.

  • Anonymous
    7 years ago

    Hey there,

    An easy to use software you can use to edit web pages is Kompozer. Link --> http://bit.ly/1rH1C1l

    It works like a charm.

  • How do you think about the answers? You can sign in to vote the answer.
  • 1 decade ago

    Hi Ben. I am sending you a complete example with both the HTML file, and the corresponding CSS file:

    estilo.css file:

    body {margin:0;padding:0;background-color:#ccc;text-align:center;}

    /*** Basic Text Formatting ***/

    p {font:0.7em/125% Verdana,sans-serif;margin-top:0px;}

    a:link {color:#900;text-decoration:none}

    a:visited {color:#900;text-decoration:none}

    a:active {color:#900;text-decoration:none}

    a:hover {color:#900;text-decoration:underline}

    index.html file:

    <html>

    <head>

    <title>Jerika</title>

    <link rel="stylesheet" type="text/css" href="estilo.css" media="screen" />

    </head>

    <body>

    <p>Parrafo</p>

    <h1>H1</h1>

    <a href='http://www.jaimemontoya.com/'%3EEnlace a Jaime Montoya</a>

    </body>

    </html>

    The line that responds your question is:

    <link rel="stylesheet" type="text/css" href="estilo.css" media="screen" />

    Remember, it must be in the <head> section of your HTML file. Take care Ben.

    Jaime Montoya

    webmaster@jaimemontoya.com

    www.jaimemontoya.com

  • 1 decade ago

    <HEAD>

    <LINK REL=stylesheet TYPE="text/css" HREF="filename.css">

    </HEAD>

    Easy as that Den.

    GL

    Ash

Still have questions? Get your answers by asking now.