...

View Full Version : Browser specific Conditionals assistence



stickybomb
07-18-2007, 04:31 PM
Not really sure where this would fall under categories, so ill try it here

ok am i all familiar with the use of conditionals to fix rendering issues with all IE browsers. I am wondering if conditionals able to determine if it is IE and differentiate between versions, or is there conditionals to test for other specific browsers.

for example lately i have been having issues with safari and would like to be able to use conditionals to write specific code for only safari or firefox.

Are there conditionals to test for this or another way to test for the specific browser i am trying to affect without the use of lengthy javascript or php code.

if anyone knows of any methods or what not pls let me know or direct me in the right direction

peace
Sticky

AndyArmstrong
07-18-2007, 04:41 PM
a nice little non javascript example is this:

<!--[If IE 7]>
<stylesheet stuff etc etc etc load this that and next thing (html)
<![endif]-->

<!--[If lt IE 6]>
<stylesheet stuff etc etc etc load this that and next thing (html)
<![endif]-->

This will only detect and be read by the different IE versions, so what i do is, the default above this is for mozilla etc - then if browser is IE, it readsd those comments and sorts the hacks accordingly!

VIPStephan
07-18-2007, 04:44 PM
Nope, conditional comments are a MS proprietary thing. After all, if you write semantic code (http://brainstormsandraves.com/articles/semantics/structure/) there shouldn’t be any issues with Safari or Firefox. CSS support is very good and consistent as well… if you do it right, of course.

AndyArmstrong
07-18-2007, 04:54 PM
what im saying is - you can pretty much therefore make the defualt for safari mozilla etc other gecko based clients - and catch IE?

ahallicks
07-18-2007, 04:58 PM
So, the answer is 'no' there are not specific conditional comments to only apply to any other browsers. As Stephan says, if you build semantic and well thought out/utilised CSS and (X)HTML code then you shouldn't be having any problems with the compliant browsers... IE has a few problems with some things, but the others are fairly similar.

If there is an issue with something not displaying in the right place try zeroing out your paddings and margins in the style sheet with * {margin: 0; padding: 0;}

stickybomb
07-18-2007, 05:47 PM
well thats what i normally do. but all of a sudden safari wants to blow up everything i am doing. Not all compliant browsers are completely the same so there are some instances where a little tweaking is involved. I was just curious if there was an easy way of detecting this there fore i would not have to go through several rewrites of my styles until they displayed correctly in both mozilla and safari

ahallicks
07-18-2007, 05:56 PM
Post a link to your problem and we might be able to help you/see something that you may have missed

_Aerospace_Eng_
07-18-2007, 07:32 PM
Post a link to your problem and we might be able to help you/see something that you may have missed

While ahallicks is correct. You may have missed something simple, conditionals for other browsers do exist. They are called downlevel conditional comments.
http://www.456bereastreet.com/archive/200511/valid_downlevelrevealed_conditional_comments/
Another good link here
http://thomas.tanreisoftware.com/?p=11

VIPStephan
07-18-2007, 08:37 PM
Another good link here
http://thomas.tanreisoftware.com/?p=11

Haven’t read the entire article but while MS’s conditional comments are exactly intended to do what they do the CSS hacks are what they are: Hacks that exploit browser shortcomings. And while conditional comments always follow their intended behavior those hacks are kind of unstable as future versions of browsers might support a rule that was used to target a single browser only, and thus render the page incorrectly.

This downlevel conditional comment is also only made for IE, though, in this case saying “if not IE …”. The other browsers can only be tricked by closing the comment to read and parse what’s there while IE gets told to not parse it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum