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 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Canada
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using a Style Sheet

    Quick question...

    I dunno if it's called a "stylesheet" or not, but that's just what I'm assuming... to my understanding, I can have a text file (*.txt) with all my style settings, then have every html page that wants to use those settings just refer to that text file - instead of having the same style tag on every page header. (This way I could modify the style settings and it would change on every page, instead of having to change every page individually.)

    Yes... I think that's what a "style sheet" is.

    Anyways, the quick question: What's the tag needed in the <head> section to tell an html document to refer to this text file for it's style settings? And is there anything special I should put in the text file, or just the style settings?

    (I searched for the answer prior to posting with little help - mainly because I didn't know how to summarise my question into a few search terms, and when I tried I got little to no help. )

    Thanks in advancefor answering my newb question.
    Tombo out.

  • #2
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    not a .txt file, a .css file "Cascading Style Sheet"
    call it inside of the header like this:
    <link rel="stylesheet" type="text/css" href="name.css" />

    an example of what goes inside of your external file would be.

    body {
    background-color:#ffffff;
    }

    this will make your background clor of the document white.
    notice it sys "body" this represents the <body> tag on your page, the background-color specifies just that.

    also you can define your own names like this

    .header {
    color:#000000;
    }

    now anytime you add class="header" inside of a tag, the text will be black
    EX: <div class="header">this text is black</div>

    the color attribute represents color of text.
    hope thats clear enough, if you need any help you can contact me or ask in the forum
    good luck

    more info can be found at
    http://www.w3schools.com/css/default.asp
    Last edited by cg9com; 12-04-2002 at 06:50 PM.

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    Glasgow, Scotland
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Tombo…

    A stylesheet is INDEED a text file but the correct suffix is .css and not .txt.

    CSS stands for Cascading Style Sheets and is good way of setting up styles to be used across a website. Or as you said "This way I could modify the style settings and it would change on every page, instead of having to change every page individually"

    The code for adding to the 'head' section is

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

    Where yourstyle is the text file you create for your website.

    meerkat
    Ya don't need a weatherman to know
    which way the wind blows...

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Originally posted by meerkat
    A stylesheet is INDEED a text file but the correct suffix is .css and not .txt.
    You could use .abcd if you wanted, as long as the server knows to serve it with the mime-type "text/css". Contrary to popular belief, file extensions really mean nothing on the web.

  • #5
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    intresting point jkd

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How about us?

    file extensions really mean nothing on the web
    But they do to us humans... While jkd probably is totally right (i wouldn't know), i personally find it preferable to give my external style sheets the extension .css, so i still know it's a style sheet lateron.
    Regards,
    Ronald.
    ronaldvanderwijden.com


  •  

    Posting Permissions

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