Disallow underscore hack
Pages 49
- Home
- About
- Avoid un anchored hovers
- Beware of box model size
- Build System
- Build System Integration
- Bulletproof font face
- Command line interface
- Contributing
- Developer Guide
- Disallow !important
- Disallow @import
- Disallow adjoining classes
- Disallow box sizing
- Disallow duplicate background images
- Disallow duplicate properties
- Disallow empty rules
- Disallow IDs in selectors
- Disallow negative text indent
- Disallow non alphabetical
- Disallow outline:none
- Disallow overqualified elements
- Disallow qualified headings
- Disallow selectors that look like regular expressions
- Disallow star hack
- Disallow too many floats
- Disallow underscore hack
- Disallow units for zero values
- Disallow universal selector
- Disallow unqualified attribute selectors
- Don't use too many font size declarations
- Don't use too many web fonts
- Headings should only be defined once
- IDE integration
- Ignoring parts of CSS during linting
- New Release
- Require all gradient definitions
- Require compatible vendor prefixes
- Require fallback colors
- Require properties appropriate for display
- Require shorthand properties
- Require standard property with vendor prefix
- Require use of known properties
- Rules
- Rules by ID
- Source Code
- Unit Tests
- Using in a Node.js Application
- Working with Rules
- Show 34 more pages…
Clone this wiki locally
The underscore hack is a technique for applying CSS properties only to Internet Explorer prior to version 7. By placing an underscore immediately before the property name, older versions of Internet Explorer treated as if the underscore isn't there while other browsers simply ignore it. For example:
.mybox {
border: 1px solid black;
padding: 5px;
width: 100px;
_width: 200px;
}In this example, the _width property is treated as if it were width by Internet Explorer 6 and earlier, so it uses the value of 200px; other browsers skip that property and use the value of 100px.
The underscore hack relies on an old CSS parser bug in Internet Explorer, and as such, some prefer not to use it.
Rule Details
Rule ID: underscore-property-hack
This rule is aimed at eliminating the use of the underscore hack in CSS. As such, the rule warns when it finds a property preceded with an underscore.
The following patterns are considered warnings:
.mybox {
border: 1px solid black;
_width: 100px;
}Further Reading
Automated linting of Cascading Stylesheets