Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I set up <link> to use the same style sheet for all pages?

    This is a real novice question but I have to ask!

    I have multiple html pages that all reside on the same web server but within different folders. I would like to use the same style sheet for all of the pages so how do I set up the <link> tag to do this?

    If possible, please can you give me an example?

    Thanks
    Last edited by rmedek; 09-14-2007 at 02:38 PM. Reason: Title! Arrggggg…

  • #2
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts
    <link href="styles/main.css" rel="stylesheet" type="text/css" media="screen" />


    instead of "styles/main.css" you point it to where your main css page resides
    you put that piece of code in the head part of all your web pages that you want to be pointing at the main css

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Or use
    Code:
    <link rel="stylesheet" href="/style.css" type="text/css">
    where the leading forward slash tells the pages to look for the stylesheet at the root of the site. Make sure any calls to images also have the leading forward slash.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    also if you just want to go up a level try

    Code:
    <link rel="stylesheet" href="./style.css" type="text/css">
    with the dot. the Dot tells it to go to parent folder
    You can not say you know how to do something, until you can teach it to someone else.

  • #5
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    And remember that the way you close the <link .... will depend on the doctype you are using:

    <link .... > - for HTML
    <link .... /> - for XHTML
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •