external style sheets

Discussion in 'HTML' started by David K, Nov 2, 2003.

  1. David K

    David K Guest

    I am trying to understand external style sheets. How does the

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

    connect to the first style sheet html document? How can it tell the other
    html documents what to do?

    Thanks,
    Dave
    David K, Nov 2, 2003
    #1
    1. Advertising

  2. David K <> wrote:
    > connect to the first style sheet html document?


    Could you explain this a little more?

    > How can it tell the
    > other html documents what to do?


    One statement alone in a document doesn't tell any other documents what to
    do. Each document must have some sort of declaration to tell it what style
    sheet to use.
    --
    Michael Wilcox
    mjwilco at yahoo dot com
    Essential Tools for the Web Developer - http://mikewilcox.t35.com
    Michael Wilcox, Nov 2, 2003
    #2
    1. Advertising

  3. David K

    David K Guest

    Michael,

    That makes sense to me, but when you name the external styles sheet with a
    ..css extension, how does it make the changes to the other html page. I'm
    learning from a book called

    PHP/MYSQL Programming for the absolute beginner.

    Some of the explanation seems to miss something, or it's just me. I know
    that the .css file and the html file have to be in the same folder, but just
    can't understand how the Link rel connects the two documents.

    Thanks
    Dave



    "Michael Wilcox" <> wrote in message
    news:uKfpb.2836$...
    > David K <> wrote:
    > > connect to the first style sheet html document?

    >
    > Could you explain this a little more?
    >
    > > How can it tell the
    > > other html documents what to do?

    >
    > One statement alone in a document doesn't tell any other documents what to
    > do. Each document must have some sort of declaration to tell it what style
    > sheet to use.
    > --
    > Michael Wilcox
    > mjwilco at yahoo dot com
    > Essential Tools for the Web Developer - http://mikewilcox.t35.com
    >
    >
    David K, Nov 2, 2003
    #3
  4. David K pounced upon this pigeonhole and pronounced:

    [top-posting fixed]
    > "Michael Wilcox" <> wrote in message
    > news:uKfpb.2836$...
    > > David K <> wrote:
    > > > connect to the first style sheet html document?

    > >
    > > Could you explain this a little more?
    > >
    > > > How can it tell the
    > > > other html documents what to do?

    > >
    > > One statement alone in a document doesn't tell any other documents what to
    > > do. Each document must have some sort of declaration to tell it what style
    > > sheet to use.


    > Michael,
    >
    > That makes sense to me, but when you name the external styles sheet with a
    > .css extension, how does it make the changes to the other html page.


    The browser reads the css file and applies the styles to the HTML.

    > I'm learning from a book called
    >
    > PHP/MYSQL Programming for the absolute beginner.


    Since it's not an HTML/CSS book, it probably already assumes the reader
    knows those subjects.

    > Some of the explanation seems to miss something, or it's just me. I know
    > that the .css file and the html file have to be in the same folder, but just
    > can't understand how the Link rel connects the two documents.


    The css file can be anywhere on your site. One common method of site
    structure would be to group HTML documents by subject in appropriate
    subdirectories. Stylesheets would also be in a subdirectory; /style is a
    good choice.

    Then all HTML documents link to it via relative links, such as:

    <style type="text/css" media="screen, projection">@import
    "../style/mainstyles.css"; </style>
    <link type="text/css" rel="stylesheet" href="../style/printstyles.css"
    media="print" />

    --
    -bts
    -This space intentionally left blank.
    Beauregard T. Shagnasty, Nov 2, 2003
    #4
  5. David K

    Richard Guest

    David K wrote:

    > I am trying to understand external style sheets. How does the


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


    > connect to the first style sheet html document? How can it tell the
    > other
    > html documents what to do?


    > Thanks,
    > Dave



    It boils down to a shortcut. lengthy stylesheets can cut down on the clutter
    in the main body more.
    What this says is, "use the coding based on this file".
    link--begin here
    type--how should I use this information?
    href--ok. where is it?
    have code will travel.

    just be sure you put no html coding in the CSS.
    Richard, Nov 3, 2003
    #5
  6. David K

    Big Bill Guest

    On Sun, 2 Nov 2003 14:59:20 -0800, "David K" <> wrote:

    >Michael,
    >
    >That makes sense to me, but when you name the external styles sheet with a
    >.css extension, how does it make the changes to the other html page. I'm
    >learning from a book called
    >
    >PHP/MYSQL Programming for the absolute beginner.
    >
    >Some of the explanation seems to miss something, or it's just me. I know
    >that the .css file and the html file have to be in the same folder, but just
    >can't understand how the Link rel connects the two documents.
    >
    >Thanks
    >Dave
    >

    Try doing a search for CSS tutorials. There are several of different
    quality around but find one that suits you and you'll be away.

    BB
    Big Bill, Nov 3, 2003
    #6
  7. David K wrote:

    > That makes sense to me, but when you name the external styles sheet
    > with a .css extension, how does it make the changes to the other html
    > page.


    There may be some misunderstanding here. CSS Style sheets don't change
    the HTML at all, they just tell the user agent (your browser) how to
    draw the elements that are there.

    If you have

    <h1>My Heading</h1>

    in your HTML document, in your stylesheet you might have

    h1 {
    font-size: 300%;
    font-weight: bold;
    }

    which tells the browser that headings should be 3x normal size and
    bold. The HTML document is intact throughout the process.

    > Some of the explanation seems to miss something, or it's just me. I
    > know that the .css file and the html file have to be in the same
    > folder, but just can't understand how the Link rel connects the two
    > documents.


    They don't actually have to be in the same folder; they can be in
    different folders so long as both are 'visible' so that the user agent
    can fetch them as needed. For example, if your documents are served
    from C:\My Web Pages\Site\ then putting your stylesheet in C:\ won't
    help you but putting them in C:\My Web Pages\Site\Style\ would.

    The LINK element's href attribute tells the user agent where to get the
    stylesheet from; once the browser has the sheet the styles it contains
    are applied to the displayed document.
    Owen Jacobson, Nov 3, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Using external style sheets

    Kevin Spencer, Jul 9, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    357
    Kevin Spencer
    Jul 9, 2003
  2. Luigi Donatello Asero

    Alternate external style sheets

    Luigi Donatello Asero, Jun 27, 2004, in forum: HTML
    Replies:
    2
    Views:
    397
    Steve Pugh
    Jun 28, 2004
  3. iamdave

    applying external style sheets

    iamdave, Jan 25, 2008, in forum: HTML
    Replies:
    5
    Views:
    461
    Adrienne Boswell
    Jan 26, 2008
  4. Carl Corcoran
    Replies:
    1
    Views:
    268
    Bob Barrows
    Nov 12, 2003
  5. Replies:
    12
    Views:
    314
    Robert Mark Bram
    Dec 3, 2004
Loading...

Share This Page