Forcing a css file with Safari

Discussion in 'HTML' started by Giuseppe Chielli, May 5, 2005.

  1. Does anyone know the way to force the link to a specific css file when
    the browser is Safari on Mac?
    For example,with Internet Explorer I can use the following syntax:

    <!--[if IE]>
    <LINK REL="stylesheet" TYPE="text/css" HREF="styles/struttura_ie.css">
    <![endif]-->

    How can I get the same results with Safari? To be sure that a particular
    css file is loaded and used...

    Thanks a lot in advance to everyone.
     
    Giuseppe Chielli, May 5, 2005
    #1
    1. Advertising

  2. Giuseppe Chielli

    Toby Inkster Guest

    Giuseppe Chielli wrote:

    > <!--[if IE]>
    > <LINK REL="stylesheet" TYPE="text/css" HREF="styles/struttura_ie.css">
    > <![endif]-->
    >
    > How can I get the same results with Safari? To be sure that a particular
    > css file is loaded and used...


    Rename your safari.css to safari.php and then:

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

    and then at the very top of safari.php, place these lines:

    <?php
    header("Content-Type: text/css");
    if (!strstr($_SERVER['HTTP_USER_AGENT'],'AppleWebKit/')) {
    echo "/* Safari only */\n";
    exit;
    }
    ?>

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, May 6, 2005
    #2
    1. Advertising

  3. Giuseppe Chielli

    Adrienne Guest

    Gazing into my crystal ball I observed Giuseppe Chielli
    <> writing in news:d5d8tr$sme$1
    @fata.cs.interbusiness.it:

    > Does anyone know the way to force the link to a specific css file when
    > the browser is Safari on Mac?
    > For example,with Internet Explorer I can use the following syntax:
    >
    ><!--[if IE]>
    ><LINK REL="stylesheet" TYPE="text/css" HREF="styles/struttura_ie.css">
    ><![endif]-->
    >
    > How can I get the same results with Safari? To be sure that a particular
    > css file is loaded and used...
    >
    > Thanks a lot in advance to everyone.
    >


    If you have access to server side, you could query the server variables
    collection, in particular the user agent. However, some browsers can lie,
    so that is still not the best aproach. Why do you need to do this? Can't
    you make your stylesheet acceptable to all modern browsers?

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, May 6, 2005
    #3
  4. Adrienne wrote:

    > If you have access to server side, you could query the server variables
    > collection, in particular the user agent.
    > However, some browsers can lie,
    > so that is still not the best aproach.


    I see that's a problem...Safari can identify itself as a different
    browser...

    > Why do you need to do this? Can't you make your stylesheet
    > acceptable to all modern browsers?


    It's strange but with the same css some buttons seems to be displayed
    differently,labels haven't their texts complete...
    IE and Firefox on Windows system see them in the same (proper) way.
    Anyway thanks a lot.
     
    Giuseppe Chielli, May 6, 2005
    #4
  5. Giuseppe Chielli

    kchayka Guest

    Giuseppe Chielli wrote:
    > Adrienne wrote:
    >
    >> Why do you need to do this? Can't you make your stylesheet
    >> acceptable to all modern browsers?

    >
    > It's strange but with the same css some buttons seems to be displayed
    > differently,labels haven't their texts complete...


    You might be trying to fix the wrong problem. If you post a URL, we can
    all take a look and maybe find another way to get the desired results.

    --
    Reply email address is a bottomless spam bucket.
    Please reply to the group so everyone can share.
     
    kchayka, May 7, 2005
    #5
  6. Giuseppe Chielli

    kchayka Guest

    Toby Inkster wrote:
    >
    > if (!strstr($_SERVER['HTTP_USER_AGENT'],'AppleWebKit/')) {
    > echo "/* Safari only */\n";


    Don't encourage browser sniffing - we all know it's A Bad Thing.

    What are the chances that an issue showing up in Safari will do likewise
    in other KHTML browsers (Konqueror & Omniweb at least), too? Or that the
    problem is limited to a particular browser version?

    --
    Reply email address is a bottomless spam bucket.
    Please reply to the group so everyone can share.
     
    kchayka, May 7, 2005
    #6
  7. Giuseppe Chielli

    Toby Inkster Guest

    kchayka wrote:
    > Toby Inkster wrote:
    >>
    >> if (!strstr($_SERVER['HTTP_USER_AGENT'],'AppleWebKit/')) {
    >> echo "/* Safari only */\n";

    >
    > Don't encourage browser sniffing - we all know it's A Bad Thing.


    Guns don't kill people. People kill people (using guns). Browser sniffing
    is a handy technique to keep in your toolbox, but should only be used for
    Good, not Evil. And of course, it should be realised that it's not always
    reliable.

    > What are the chances that an issue showing up in Safari will do likewise
    > in other KHTML browsers (Konqueror & Omniweb at least), too? Or that the
    > problem is limited to a particular browser version?


    AppleWebKit is an embeddable HTML rendering control provided by the
    operating system, based on KHTML. Safari and Omniweb both use AppleWebKit,
    so ought to both send AppleWebKit in the user-agent string. That's why I
    chose to sniff for 'AppleWebKit/' and not 'Safari'.

    The problem may also turn up in Konqueror, but from the OP's later post,
    it looks like the problem is related to form inputs, which are rendered
    completely differently under AppleWebKit and the original KHTML, so you
    probably wouldn't want to send that stylesheet to Konqueror.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, May 7, 2005
    #7
  8. kchayka ha scritto:

    > You might be trying to fix the wrong problem. If you post a URL, we can
    > all take a look and maybe find another way to get the desired results.
    >

    Ok,thanks a lot. I'll do it as soon as possible, today I'm not
    working... ;) Please,don't abandon this thread, please.
     
    Giuseppe Chielli, May 7, 2005
    #8
  9. kchayka wrote:

    > You might be trying to fix the wrong problem. If you post a URL, we can
    > all take a look and maybe find another way to get the desired results.
    >


    URL: http://www.sit-puglia.it/bdt/webgis.asp

    You should note that the text on the button is "Rimuovi Tutt" but it
    should be "Rimuovi Tutti". Then if you click on "Crea Mappa" and see the
    table of contents on the right side of the map you will see something
    wrong in the button "Aggiorna" and so on..

    Thanks a lot.
     
    Giuseppe Chielli, May 9, 2005
    #9
  10. Giuseppe Chielli

    kchayka Guest

    Giuseppe Chielli wrote:
    > kchayka wrote:
    >
    >> You might be trying to fix the wrong problem.

    >
    > URL: http://www.sit-puglia.it/bdt/webgis.asp
    >
    > You should note that the text on the button is "Rimuovi Tutt" but it
    > should be "Rimuovi Tutti".


    This behavior is not limited to Safari.

    The problem is you have set the width of the input buttons to 85px, but
    you have no idea what font-size will actually be used. If the visitor
    uses a larger font size than you expect, the text will be clipped. This
    is true with just about any browser except IE. If you don't believe
    this, try text zoom in Firefox and see what happens.

    First, don't set font-size in pt units. They are not suitable for screen
    display (px is just as bad). The subject of font-size has been done ad
    nauseam so google the archives if you want more info on it.

    Set the input widths in em units, then they will adjust with text size.

    --
    Reply email address is a bottomless spam bucket.
    Please reply to the group so everyone can share.
     
    kchayka, May 10, 2005
    #10
    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. Nick Howes

    CSS Safari Problem

    Nick Howes, Nov 4, 2003, in forum: HTML
    Replies:
    4
    Views:
    4,982
    Nick Howes
    Nov 7, 2003
  2. Pan
    Replies:
    17
    Views:
    655
    thequad
    Aug 15, 2006
  3. Replies:
    13
    Views:
    694
    Beauregard T. Shagnasty
    Nov 30, 2005
  4. Replies:
    1
    Views:
    460
    Beauregard T. Shagnasty
    Mar 18, 2006
  5. Brett  Kelly
    Replies:
    1
    Views:
    705
    Steve C. Orr [MVP, MCSD]
    Jun 16, 2006
Loading...

Share This Page