Shaun Mccran

My digital playground

26
N
O
V
2008

Internet Explorer (IE) CSS hack using underscore

Often when developing an application I might have to stray onto the front end of an application (say the designer is on holiday or something). It goes without saying that your application should work AND look the same whatever the browser, and we all know that there are cross browser compatibility issues....

Normally I would either create a script to detect the browser type and version, and then load a browser specific version of the stylesheet.

Today tho I wandered into the '_' fix for IE. I say that its a fix for IE, as the content works as expected in FF.

It turns out that IE will read CSS values that have been prefixed with an underscore. So you can override specific settings with IE only version, like below:

view plain print about
1CREATE TABLE #temp (
2 table_name sysname ,
3 row_count int,
4 reserved_size varchar(50),
5 data_size varchar(50),
6 index_size varchar(50),
7 unused_size varchar(50))
8
9SET NOCOUNT ON
10INSERT #temp exec sp_msforeachtable 'sp_spaceused ''?'''
11
12SELECT a.table_name, a.row_count, count(*) AS col_count, a.data_size
13FROM #temp a
14    INNER JOIN information_schema.columns b on a.table_name = b.table_name
15    GROUP BY a.table_name, a.row_count, a.data_size
16    ORDER BY CAST(Replace(a.data_size, ' KB', '') AS integer) DESC
17DROP TABLE #temp

The red background color will be ignored by everyone other than IE browsers.

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Back to top