TAILIEUCHUNG - The CSS Anthology: 101 Essential Tips, Tricks & Hacks- P14

The CSS Anthology: 101 Essential Tips, Tricks & Hacks- P14:Apart from writing books like this one, I write code. I make my living by building web sites and applications as, I’m sure, many readers of this book do. I use CSS to complete jobs every day, and I know what it’s like to struggle to make CSS work when the project needs to be finished the next morning. | Cross-browser Techniques 237 -- if IE 7 link rel stylesheet type text css href endif -- This code will reveal a style sheet to all versions of Internet Explorer less than or equal to version 7 -- if lte IE 7 link rel stylesheet type text css href endif -- The conditional comments need to go into the head of your document you must include them after your main style sheet otherwise rules in your IE-only style sheet will be overwritten by rules in your main style sheet. There are many more options available in the syntax of the condition. If you want to know more about conditional comments the SitePoint CSS Reference has a useful In the solutions that follow we ll look at the use of conditional comments to serve Internet Explorer 6 an additional style sheet as well as a JavaScript file. How do I deal with the most common issues in IE6 and 7 Internet Explorer 6 and to a lesser extent 7 are the browsers that you re most likely to have problems with today. By using methodical working practices you should be able to make your sites work well in these browsers but still be able to push ahead with complex layouts taking advantage of the excellent CSS support in modern browsers. Solution The following are my suggestions for a CSS working method along with tips to help you make IE6 and 7 behave. 23 http css conditionalcomments Download at 238 The CSS Anthology The Development Process Here s how I work to avoid as many IE6 and 7 issues as possible. Develop Using an Up-to-date Browser You should initially develop your layout in a browser that complies with the CSS specification well for example the latest versions of Firefox Opera and Safari. Browsers are becoming more standards-compliant not less so you want to ensure that the CSS you write today complies with the specification because it s more likely to behave in future browsers. I never look at the layout in Internet Explorer while building a web site. If