Forcing a css file with Safari

  • Thread starter Giuseppe Chielli
  • Start date
G

Giuseppe Chielli

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.
 
T

Toby Inkster

Giuseppe said:
<!--[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;
}
?>
 
A

Adrienne

Gazing into my crystal ball I observed Giuseppe Chielli
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?
 
G

Giuseppe Chielli

Adrienne said:
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.
 
K

kchayka

Giuseppe said:
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.
 
K

kchayka

Toby said:
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?
 
T

Toby Inkster

kchayka said:
Toby said:
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.
 
G

Giuseppe Chielli

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.
 
G

Giuseppe Chielli

kchayka said:
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.
 
K

kchayka

Giuseppe said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,573
Members
45,046
Latest member
Gavizuho

Latest Threads

Top