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 4 ms
NrQueryErrorAffectedNum. rowsTook (ms)
1DESCRIBE `posts`17171
2DESCRIBE `comments`11111
3DESCRIBE `tags`221
4DESCRIBE `categories`220
5DESCRIBE `posts_tags`220
6DESCRIBE `categories_posts`221
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 1110
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) 000
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`) 110
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` = 1210