|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
100% Windoze-free
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Feb 2003
Location: Ubuntuland
Posts: 2,782
|
Hiding styles from browsers/platforms?
I use the basic link and @import combo to hide certain rules from NN 4.79.
I have read elsehwere, in bits and pieces, that it is possible to exclude browsers on various platforms from reading styles by using the media attribute etc. Could someone please point me to a definitive list of configurations? I'd also like some advice on the order of listing these exclusionary tricks. Would be nice to gather a comprehensive list all in one thread, don't you think? Thanks.
Edit: Oops. This should probably be posted in CSS. Guess I forgot where I was! |
|
|
|
|
|
#2 |
|
☆★☆★
![]() Join Date: Jan 2002
Location: in transition
Posts: 21,423
|
To hide style from NN4:
Code:
@import url(styles.css); Code:
@import "styles.css"; Code:
@import "styles.css" screen; Code:
@media screen {
/*rules here*/
}
|
|
|
|
|
|
#3 |
|
CSS Advisor
![]() ![]() ![]() ![]() Join Date: Jan 2003
Location: Hampshire UK
Posts: 29,644
|
Here's a couple of useful links.
http://www.ericmeyeroncss.com/bonus/trick-hide.html http://w3development.de/css/hide_css...wsers/summary/ Paul |
|
|
|
|
|
#4 |
|
100% Windoze-free
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Feb 2003
Location: Ubuntuland
Posts: 2,782
|
Thanks guys. That's exactly what I was looking for.
![]() |
|
|
|
|
|
#5 | |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2004
Location: Earth
Posts: 614
|
Quote:
Here's a few others I like. This one hides rules from Safari, mac/ie5 and Konqueror: Code:
@media ScReEn { ... }
Code:
selector[foo^="bar"] Code:
selector/**/[foo="bar"] Code:
* html selector { ... } /* all versions of IE */
* html*selector { ... } /* 5.5+ only */
|
|
|
|
|
|
|
#6 |
|
SitePoint Enthusiast
![]() Join Date: Feb 2004
Location: The Netherlands
Posts: 45
|
This is also a good resource about CSS browser filters:
http://www.centricle.com/ref/css/filters/ |
|
|
|
|
|
#7 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2004
Location: Earth
Posts: 614
|
And there's some more charts at http://www.dithered.com/css_filters/index.html
|
|
|
|
|
|
#8 |
|
CSS Advisor
![]() ![]() ![]() ![]() Join Date: Jan 2003
Location: Hampshire UK
Posts: 29,644
|
*>html .targetelement {css rules only IE/mac can see}
|
|
|
|
|
|
#9 |
|
SitePoint Zealot
![]() ![]() Join Date: Feb 2001
Posts: 176
|
Pop your style sheets into the top of your javascript for an easy way to deliver an alternative style to Javascript enabled browsers:
document.write("<style type=\"text/css\" media=\"screen\">@import \"s/jsbrowser.css\";</style>"); Just make sure it comes after your non-javascript style. |
|
|
|
|
|
#10 | |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2004
Location: Earth
Posts: 614
|
Quote:
|
|
|
|
|
|
|
#11 |
|
CSS Advisor
![]() ![]() ![]() ![]() Join Date: Jan 2003
Location: Hampshire UK
Posts: 29,644
|
|
|
|
|
|
|
#12 |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2004
Location: Earth
Posts: 614
|
Ta
![]() |
|
|
|
|
|
#13 | |
|
SitePoint Zealot
![]() ![]() Join Date: Jan 2004
Location: west of the divide
Posts: 154
|
Eric Meyer points out (from the article linked above):
Quote:
But my initial tests suggest that you can get around this with a redundant screen specification. That is, if you want to hide a screen-only stylesheet from NN4, you can use HTML Code:
<link rel="stylesheet" type="text/css" href="advanced-styles.css"
[b]media="screen, screen"[/b]>
|
|
|
|
|
|
|
#14 |
|
SitePoint Zealot
![]() ![]() Join Date: Mar 2004
Location: Lovely Leipzig
Posts: 166
|
Why use hacks at all?
Hi guys, I'm new to this forum so I don't want to get anybody's backs up but this has been bothering me for a while now.
Why dirty up your beautifully crafted css with all these hacks? My experience has been that you use one hack only to discover that it messes up in another browser. Why not just pull out the user-agent field from the http header with php/jsp/asp and use an include to attach an appropriate style? Maybe I'm talking rubbish but it seems to be a more elegant solution. Most of the stable styles could go in a common sheet and the browser specific ones delivered as appropriate. Then just eliminate them as browsers comply over the next few years. Mostly it would mean we don't have to clutter our brains with work arounds and get down to the business of providing usable, accessible, funky lookin' sites. |
|
|
|
|
|
#15 | |
|
CSS Advisor
![]() ![]() ![]() ![]() Join Date: Jan 2003
Location: Hampshire UK
Posts: 29,644
|
Quote:
As for serving a different stylesheet for each browser I think that could be more of a headache in the long run. Most hacks are simple one line affairs that follow an existing style. Consider this: Code:
#test {
height:100%;
min-height:100%;
}
html>body #test {height:auto}
I don't know anything about getting user agent fields from http headers but I thought it was difficult as browsers tend not to identify themselves correctly (e.g. Opera ) (but I may be wrong )Paul |
|
|
|
|
|
|
#16 | ||
|
SitePoint Enthusiast
![]() Join Date: Feb 2004
Location: The Netherlands
Posts: 45
|
Quote:
- write validating CSS that works in Mozilla Firefox (my browser of choice) - test in Internet Explorer and correct any bugs and use hacks to filter it for IE only I usually don't really bother with any other browsers, because they'll do a well enough job with the valid CSS. Older browsers get unstyled content. Also, I only use filters that pass through the W3C validator. Quote:
|
||
|
|
|
|
|
#17 | |
|
SitePoint Guru
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2004
Location: Earth
Posts: 614
|
Quote:
|
|
|
|
|
|
|
#18 |
|
SitePoint Enthusiast
![]() Join Date: Sep 2003
Location: Singapore
Posts: 42
|
How about MSIE's conditional comments?
I think they are pretty useful, since MSIE requires demonic hacks... (And i hope that IE Longhorn has them to serve as our insurance..) |
|
|
|
|
|
#19 |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Dec 2001
Posts: 222
|
IE conditional comments
IE's conditional comments are okay if you just want to detect any version of IE.
If you want to differentiate between versions of IE you have to have your test versions running on separate copies of Windows. If you're using multiple versions of IE on one copy of Windows (http://www.skyzyx.com/archives/000094.php) then they all report the latest version on your system. Paul made the point earlier - CSS hacks work even when browsers mis-report their identity. |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 09:22.















Linear Mode
