Stylesheet question

Discussion in 'HTML' started by Samuël van Laere, Nov 2, 2003.

  1. Currently i offer 4 stylesheets,
    the user can use the php based style switcher to select a different
    stylesheet. (code was found on this group :))

    Do i also need to link the stylesheets in the html as alternate stylesheet?

    Or isn't there any need, since i allready offer a way of picking a different
    stylesheet?



    --
    With regards,
    Samuël van Laere
    the Netherlands
    http://www.fortron.net
    Samuël van Laere, Nov 2, 2003
    #1
    1. Advertising

  2. Am 02.11.2003 14:15 schrieb Samuël van Laere:
    > Do i also need to link the stylesheets in the html as alternate stylesheet?
    >
    > Or isn't there any need, since i allready offer a way of picking a different
    > stylesheet?

    There is no need for that in technical sense. But Mozilla(Firebird)
    users will be happier, since their browsers offer to change style sheets
    based on the <link>-tag in your HTML code, without having to use your
    PHP script.

    So if you can offer it, do it.

    Fabian
    Fabian Neumann, Nov 2, 2003
    #2
    1. Advertising

  3. In article Samuël van Laere wrote:
    > Currently i offer 4 stylesheets,
    > the user can use the php based style switcher to select a different
    > stylesheet. (code was found on this group :))


    OK.

    > Do i also need to link the stylesheets in the html as alternate stylesheet?


    It wouldn't do much harm.

    > Or isn't there any need, since i allready offer a way of picking a different
    > stylesheet?


    Not with current implementions of browsers, on normal situations.

    I don't think multible stylesheets for same media are usefull exept maybe
    when there is some idiot boss somewhere that demands bells and whisles,
    and only way to get reasonable style is to do it using alternate
    stylesheet (and then look server logs in hope alternate stylesheet will
    be used more than default).

    Of course, there is exeptions.


    Of course, if one aim is to learn how to make stylesheets, it doesn't
    hurt to put them in use. But for webpage, it usually is more usefull to
    add more content.

    --
    Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
    Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
    tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.
    Lauri Raittila, Nov 2, 2003
    #3
  4. Fabian Neumann wrote:

    > There is no need for that in technical sense. But Mozilla(Firebird)
    > users will be happier, since their browsers offer to change style sheets
    > based on the <link>-tag in your HTML code, without having to use your
    > PHP script.


    Ditto regular Mozilla, ditto Opera, ditto Konqueror[1].

    *However* a PHP style switcher is in many ways *better* than just relying
    on rel="alternate stylesheet", as browsers don't[2] carry over the choice
    of an alternate stylesheet when you go on to the next page :-(

    Of course, *best* is to offer both. (Which I do)

    [1] Konqueror 3 does funny things with alternate style sheets. When a list
    of alternate stylesheets is given, it uses the first one by default! I
    have yet to add a workaround to my site, although I do plan to do so[3].
    Safari does not suffer from this bug. More details here:
    http://bugs.kde.org/show_bug.cgi?id=54335

    [2] Except Konqueror.

    [3] I generally don't work around bugs in browsers, but the fix should be
    pretty easy.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
    Toby A Inkster, Nov 2, 2003
    #4
  5. Fabian Neumann <> wrote:
    > But Mozilla(Firebird)
    > users will be happier, since their browsers offer to change style
    > sheets based on the <link>-tag in your HTML code


    What exactly is this code?
    --
    Michael Wilcox
    mjwilco at yahoo dot com
    Essential Tools for the Web Developer - http://mikewilcox.t35.com
    Michael Wilcox, Nov 2, 2003
    #5
  6. "Toby A Inkster" <> schreef in bericht
    news:p...
    > Fabian Neumann wrote:
    >
    > > There is no need for that in technical sense. But Mozilla(Firebird)
    > > users will be happier, since their browsers offer to change style sheets
    > > based on the <link>-tag in your HTML code, without having to use your
    > > PHP script.

    >
    > Ditto regular Mozilla, ditto Opera, ditto Konqueror[1].
    >
    > *However* a PHP style switcher is in many ways *better* than just relying
    > on rel="alternate stylesheet", as browsers don't[2] carry over the choice
    > of an alternate stylesheet when you go on to the next page :-(
    >
    > Of course, *best* is to offer both. (Which I do)
    >
    > [1] Konqueror 3 does funny things with alternate style sheets. When a list
    > of alternate stylesheets is given, it uses the first one by default! I
    > have yet to add a workaround to my site, although I do plan to do so[3].
    > Safari does not suffer from this bug. More details here:
    > http://bugs.kde.org/show_bug.cgi?id=54335
    >
    > [2] Except Konqueror.
    >
    > [3] I generally don't work around bugs in browsers, but the fix should be
    > pretty easy.
    >
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
    >


    Fabian and Toby,
    thanks for the answers they are mosy usefull.
    What kind of workaround could i use?
    I wonder if i should bother anyhow, the next build/version is likely to
    solve that isue right?



    --
    With regards,
    Samuël van Laere
    the Netherlands
    http://www.fortron.net
    Samuël van Laere, Nov 2, 2003
    #6
  7. "Toby A Inkster" <> schreef in bericht
    news:p...
    > Fabian Neumann wrote:
    >
    > > There is no need for that in technical sense. But Mozilla(Firebird)
    > > users will be happier, since their browsers offer to change style sheets
    > > based on the <link>-tag in your HTML code, without having to use your
    > > PHP script.

    >
    > Ditto regular Mozilla, ditto Opera, ditto Konqueror[1].
    >
    > *However* a PHP style switcher is in many ways *better* than just relying
    > on rel="alternate stylesheet", as browsers don't[2] carry over the choice
    > of an alternate stylesheet when you go on to the next page :-(
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
    >


    I'm using the script you wrote Toby (i think) it works great :)



    --
    With regards,
    Samuël van Laere
    the Netherlands
    Samuël van Laere, Nov 2, 2003
    #7
  8. Samuël van Laere

    David Graham Guest

    > I'm using the script you wrote Toby (i think) it works great :)
    >

    Any chance of making it available for me.

    thanks
    David
    David Graham, Nov 4, 2003
    #8
  9. "David Graham" <> schreef in bericht
    news:CoNpb.345$...
    > > I'm using the script you wrote Toby (i think) it works great :)
    > >

    > Any chance of making it available for me.
    >
    > thanks
    > David
    >
    >


    Hello David,

    This is the code as it was published by Toby:
    ============================ example.php =============================
    <!DOCTYPE whatever>
    <?php
    $s = $_GET['style'];
    if (!($s)) { $s = 'red'; }
    ?>
    <html>
    <head>
    <title>Example</title>
    <link rel="stylesheet" type="text/css" media="screen,projection"
    <?php echo ' href="styles/' . $s . '.css"'; ?> >
    </head>
    <body>
    <h1>Example</h1>
    <p>The style you chose was <code><?php echo $s ?>.css</code>.</p>
    <ul>
    <li><a href="example.org?style=red">Red</a></li>
    <li><a href="example.org?style=white">White</a></li>
    <li><a href="example.org?style=black">Black</a></li>
    </ul>
    </body>
    </html>
    ======================================================================


    With regards,
    Samuël van Laere
    the Netherlands
    http://www.fortron.net
    Samuël van Laere, Nov 4, 2003
    #9
  10. Samuël van Laere

    David Graham Guest


    >
    > Hello David,
    >
    > This is the code as it was published by Toby:
    > ============================ example.php =============================
    > <!DOCTYPE whatever>
    > <?php
    > $s = $_GET['style'];
    > if (!($s)) { $s = 'red'; }
    > ?>
    > <html>
    > <head>
    > <title>Example</title>
    > <link rel="stylesheet" type="text/css" media="screen,projection"
    > <?php echo ' href="styles/' . $s . '.css"'; ?> >
    > </head>
    > <body>
    > <h1>Example</h1>
    > <p>The style you chose was <code><?php echo $s ?>.css</code>.</p>
    > <ul>
    > <li><a href="example.org?style=red">Red</a></li>
    > <li><a href="example.org?style=white">White</a></li>
    > <li><a href="example.org?style=black">Black</a></li>
    > </ul>
    > </body>
    > </html>
    > ======================================================================
    >
    >
    > With regards,
    > Samuël van Laere
    > the Netherlands
    > http://www.fortron.net
    >

    Many thanks
    David
    David Graham, Nov 4, 2003
    #10
  11. Samukl van Laere wrote in alt.html:

    > Hello David,
    >
    > This is the code as it was published by Toby:
    > ============================ example.php =============================
    > <!DOCTYPE whatever>
    > <?php
    > $s = $_GET['style'];
    > if (!($s)) { $s = 'red'; }
    > ?>
    > <html>
    > <head>
    > <title>Example</title>
    > <link rel="stylesheet" type="text/css" media="screen,projection"
    > <?php echo ' href="styles/' . $s . '.css"'; ?> >
    > </head>
    > <body>
    > <h1>Example</h1>
    > <p>The style you chose was <code><?php echo $s ?>.css</code>.</p>
    > <ul>
    > <li><a href="example.org?style=red">Red</a></li>
    > <li><a href="example.org?style=white">White</a></li>
    > <li><a href="example.org?style=black">Black</a></li>
    > </ul>
    > </body>
    > </html>
    > ======================================================================


    One might note that there's a potential security issue with allowing
    the user to put anything they want in the $s variable. A more robust
    script might look like

    <?php
    $styletag = $_REQUEST['s']; // explicit import
    $stylesheet = "default.css";

    // map style tags to actual stylesheets
    if ($styletag == 'red')
    $stylesheet = "red.css";
    elseif ($styletag == 'white')
    $styletag = "white.css";
    elseif ($styletag == 'black')
    $styletag = "black.css";

    // Use php echo stylemap('/foo/bar.php'); for all links that should
    // propagate style information
    function stylemap ($url) {
    global $styletag;
    return $url . "?s=" . $styletag;
    }

    .....the rest of your script....
    ?>
    <!DOCTYPE ...>
    <html>
    <head>
    <title>Page Title</title>
    <link rel="stylesheet" type="text/css" href="<?php echo $stylesheet;
    ?>">
    <link rel="alternate stylesheet" ...alternate stylesheet links...>
    </head>
    .....the rest of your page....

    <a href="<?php echo stylemap('links.php'); ?>">links</a> (for example)

    All code untested and written off the cuff
    Owen Jacobson, Nov 4, 2003
    #11
  12. Owen Jacobson wrote:
    > Samukl van Laere wrote in alt.html:
    >> Hello David,
    >> This is the code as it was published by Toby:
    >> ============================ example.php =============================
    >> <!DOCTYPE whatever>
    >> <?php
    >> $s = $_GET['style'];
    >> if (!($s)) { $s = 'red'; }
    >> ?>

    [snip]
    >> <link rel="stylesheet" type="text/css" media="screen,projection"
    >> <?php echo ' href="styles/' . $s . '.css"'; ?> >

    [snip]
    > One might note that there's a potential security issue with allowing
    > the user to put anything they want in the $s variable.


    There is no security issue. So what if the user puts something odd in $s?
    It's not like I did an "include($s)".

    [newsgroups set back to include alt.html, as I don't read comp.lang.php --
    PHP sucks]

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
    Toby A Inkster, Nov 4, 2003
    #12
  13. Toby A Inkster <> wrote in message news:<>...

    <snip>

    > [newsgroups set back to include alt.html, as I don't read comp.lang.php --
    > PHP sucks]


    Then why stay here? Just get lost out of PHP.

    ---
    "If there is a God, he must be a sadist!"
    Email: rrjanbiah-at-Y!com
    R. Rajesh Jeba Anbiah, Nov 5, 2003
    #13
  14. Am 02.11.2003 23:42 schrieb Michael Wilcox:

    > Fabian Neumann <> wrote:
    >
    >>But Mozilla(Firebird)
    >>users will be happier, since their browsers offer to change style
    >>sheets based on the <link>-tag in your HTML code

    >
    >
    > What exactly is this code?


    For example:

    <link rel="stylesheet" type="text/css" media="screen" title="default"
    href="default.css" />
    <link rel="alternate stylesheet" type="text/css" media="screen"
    title="redstyle" href="red.css" />
    <link rel="alternate stylesheet" type="text/css" media="screen"
    title="bluestyle" href="blue.css" />
    Fabian Neumann, Nov 8, 2003
    #14
  15. Fabian Neumann <> wrote:
    > <link rel="stylesheet" type="text/css" media="screen" title="default"
    > href="default.css" />
    > <link rel="alternate stylesheet" type="text/css" media="screen"
    > title="redstyle" href="red.css" />
    > <link rel="alternate stylesheet" type="text/css" media="screen"
    > title="bluestyle" href="blue.css" />


    This isn't working for me in a test page. Do you have a working example?
    --
    Michael Wilcox
    mjwilco at yahoo dot com
    Essential Tools for the Web Developer - http://mikewilcox.t35.com
    Michael Wilcox, Nov 8, 2003
    #15
  16. Samuël van Laere

    picayunish Guest

    Michael Wilcox wrote in
    news:X9arb.17051$:
    > Fabian Neumann <> wrote:
    >> <link rel="stylesheet" type="text/css" media="screen" title="default"
    >> href="default.css" />
    >> <link rel="alternate stylesheet" type="text/css" media="screen"
    >> title="redstyle" href="red.css" />
    >> <link rel="alternate stylesheet" type="text/css" media="screen"
    >> title="bluestyle" href="blue.css" />

    >
    > This isn't working for me in a test page.


    Probably you tested with IE.
    IE doesn't support alternative stylesheet like NS, Moz, Firebird, Opera,
    etc.

    > Do you have a working example?


    A working example of mister M. B. Stevens http://www.mbstevens.com/
    Or Toby A Inkster's site http://www.goddamn.co.uk/tobyink/
    --
    Edwin van der Vaart
    http://www.semi-conductor.nl/ Links to Semiconductors sites
    http://members.chello.nl/e.vandervaart/ Experimental site
    picayunish, Nov 8, 2003
    #16
  17. Toby A Inkster, Nov 8, 2003
    #17
  18. picayunish <> wrote:
    > Probably you tested with IE.
    > IE doesn't support alternative stylesheet like NS, Moz, Firebird,
    > Opera, etc.


    Actually I did test in Mozilla, which was why I was confused, but I got it
    now (don't know what happened). Thanks!
    --
    Michael Wilcox
    mjwilco at yahoo dot com
    Essential Tools for the Web Developer - http://mikewilcox.t35.com
    Michael Wilcox, Nov 9, 2003
    #18
    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. Uli

    stylesheet question

    Uli, Jul 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    328
  2. =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

    Stylesheet referanse i stylesheet

    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=, Jul 3, 2004, in forum: XML
    Replies:
    3
    Views:
    557
    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=
    Jul 4, 2004
  3. Steven An
    Replies:
    1
    Views:
    486
    Martin Honnen
    Nov 23, 2004
  4. David Blickstein
    Replies:
    3
    Views:
    1,020
    David Blickstein
    Aug 2, 2005
  5. David Blickstein
    Replies:
    14
    Views:
    6,297
    Harrie
    Oct 16, 2005
Loading...

Share This Page