IE specific CSS without hacking

You can customize your CSS for the many IE faults by using the conditional comments in your html document.

For example to include an additional CSS script containing all your IE hacks you would add the following after your main CSS include:

Show Plain Text
HTML code
  1. <!--[if IE]>
  2. <link rel="stylesheet" href="ie.css" type="text/css" />
  3. <![endif]-->

The conditional comments can be specific to a version of IE, for example <!--[if lt IE 7]> will target all versions of the IE browser less than 7. For further options refer to the MSDN page About Conditional Comments.

Why bother you say? My original motivation was to get W3C CSS compliance which does not take into account everyone needs to hack IE to get things displayed correctly. Having a separate CSS file also allows me to centralize my hacks for IE.

This may help with the hacks IE requires but doesn't help with other browsers hacks that might crop up, however since IE (for some unknown reason) is still the dominant browser it will have to do for the present time.

Filed under: Design  Tags: Css

0 Responses to “IE specific CSS without hacking”

Sorry, comments have been closed for this post.
(default) 11 queries took 151 ms
NrQueryErrorAffectedNum. rowsTook (ms)
1DESCRIBE `posts`171713
2DESCRIBE `comments`111113
3DESCRIBE `tags`221
4DESCRIBE `categories`2229
5DESCRIBE `posts_tags`2227
6DESCRIBE `categories_posts`2212
7SELECT `Post`.`id`, `Post`.`url`, `Post`.`title`, `Post`.`icon`, `Post`.`metadesc`, `Post`.`metakeys`, `Post`.`categories`, `Post`.`tease`, `Post`.`body`, `Post`.`private_body`, `Post`.`created`, `Post`.`modified`, `Post`.`status`, `Post`.`allow_comments`, `Post`.`tags`, `Post`.`hitcount`, `Post`.`hitcount_rss` FROM `posts` AS `Post` WHERE `Post`.`url` = 'ie-specific-css-without-hacking' LIMIT 11122
8SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`body`, `Comment`.`author`, `Comment`.`url`, `Comment`.`email`, `Comment`.`ip`, `Comment`.`status`, `Comment`.`junk_score`, `Comment`.`created`, `Comment`.`modified` FROM `comments` AS `Comment` WHERE `Comment`.`status` = 2 AND `Comment`.`post_id` = (12) 0011
9SELECT `Tag`.`id`, `Tag`.`tag`, `PostsTag`.`post_id`, `PostsTag`.`tag_id` FROM `tags` AS `Tag` JOIN `posts_tags` AS `PostsTag` ON (`PostsTag`.`post_id` = 12 AND `PostsTag`.`tag_id` = `Tag`.`id`) 111
10SELECT `Category`.`id`, `Category`.`category`, `CategoriesPost`.`post_id`, `CategoriesPost`.`category_id` FROM `categories` AS `Category` JOIN `categories_posts` AS `CategoriesPost` ON (`CategoriesPost`.`post_id` = 12 AND `CategoriesPost`.`category_id` = `Category`.`id`) 110
11UPDATE `posts` AS `Post` SET `Post`.`hitcount` = Post.hitcount + 1 WHERE `Post`.`id` = 12122