Email
Share

We Rock Your Web Forum » Markup Languages » CSS

CSS External Style Sheet Example?

(4 posts)
  1. andy

    member
    Joined: Aug '09
    Posts: 15

    I've been applying my styles via inline code all this time. Can someone give me a refresher on how to link an external style sheet by providing an example?

    Posted 2 years ago #

  2. Posted 2 years ago
  3. miraculix

    member
    Joined: Aug '09
    Posts: 27

    No problem Andy. Just add the following in the header of your web page file:

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

    Note the XHTML compliance.

    Posted 2 years ago #
  4. andy

    member
    Joined: Aug '09
    Posts: 15

    Cool beans, thanks. What about the third way to do it - where the code comes in the header? I think it's called an internal style sheet?

    Posted 2 years ago #
  5. miraculix

    member
    Joined: Aug '09
    Posts: 27

    Yep, there's three ways to do a stylesheet:

    1. External (shown above)
    2. Internal
    3. Inline

    Examples of the last two follow:

    Internal:
    <head>
    <style type="text/css">
    styles...
    </style>
    </head>

    Inline:
    <p style="styles...">Bla bla.</p>

    You can also import a stylesheet:
    <style type="text/css" media="all">@import "/styles.css";</style>

    Although I think importing a stylesheet uses more overhead than the direct external method.

    Posted 2 years ago #

RSS feed for this topic

Reply

(required)

Allowed markup: BBcode blockquote code em strong ul ol li font strike center u hr.
You can also put code in between backtick ( ` ) characters.