HTML and CSS Reference
In-Depth Information
years. Also, remember to use the validator throughout the coding process, and not just at the
end.
What about the other two CSS errors that aren't related to vendor prefixes? Those two errors
are due to the fact that two of our CSS declarations begin with an asterisk character. Those
asterisked declarations are CSS hacks. The first example is part of our clearfix code and the
other helps us to align our navigation elements. Let's take a moment to consider these types
of hacks.
CSS Hacks
As previously mentioned, this final chapter is not an extensive discussion of browser-specific
issues, but it's important to be familiar with the concept of CSS hacks, as they've been valu-
able tools in many a CSS developer's box of tricks over the years.
A CSS hack is basically a line or block of code in a CSS file that only a specific browser, or
browser version, understands. So if we run into a problem that only happens in one browser,
we may have the option to use a CSS hack to target only that browser in order to fix the prob-
lem.
But a word of caution: A CSS hack should not be used unless all other possible valid solu-
tions have been tried and exhausted. The rest of this chapter outlines some principles and
techniques to help solve problems in CSS without the use of hacks. But as a last resort, for a
list of possible CSS hacks, or to learn different ways to target older versions of Internet Ex-
plorer (which is the browser that's most frequently targeted by hacks), here are three articles
to bookmark and refer to:
"Conditional Stylesheets vs CSS Hacks? Answer: Neither!" by Paul Irish
"Browser [-specific] CSS Hacks" by Paul Irish
"How Do I Target IE7 or IE8 Using CSS Hacks?" by Louis Lazaris
Reduced Test Cases
Reduced test cases are invaluable for debugging particularly knotty problems in CSS. A re-
duced test case is a bare-bones version that displays the same behaviour as the problem in
question.
Search WWH ::




Custom Search