Disallow outline:none
Pages 48
- 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 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 33 more pages…
Clone this wiki locally
The CSS outline property is used to define a border around elements. Unlike the border property, the outline property does not alter the size or layout of the element. Because of this, browsers frequently use outline as the specification for an active state. In Internet Explorer and Firefox, the outline of a selected element is a single pixel dotted line when focus has moved to that element.
The focus outline is important for accessibility because it gives a visual indication as to where the focus is on the page. For keyboard-only users, tracking the focus on a web page is impossible without the visual indication given by the focus outline. Unfortunately, some consider the focus outline to be "ugly" or unappealing, and remove it using code such as :
a {
outline: none;
}Or:
a {
outline: 0;
}Both of these will remove the outline from an element, so it won't appear even when focus has moved to that element. This is very bad for accessibility.
Of course, there are times when you may want to provide a custom focus decoration for users instead of the default dotted border. In those instances, it's appropriate to remove the outline and add another treatment. The best way to do this is to use :focus and provide the alternate treatment along with resetting outline, such as:
a:focus {
border: 1px solid red;
outline: none;
}Rule Details
Rule ID: outline-none
This rule is aimed at ensuring keyboard-only users have a visual indicator of focus. As such, the rule warns when it finds:
-
outline: noneoroutline: 0in any rule whose selectors doesn't contain:focus -
outline: noneoroutline: 0in any rule whose selectors contains:focusand the rule doesn't contain any other properties
The following patterns are considered warnings:
/* no :focus */
a {
outline: none;
}
/* no :focus */
a {
outline: 0;
}
/* :focus but missing a replacement treatment */
a:focus {
outline: 0;
}The following pattern is considered okay and does not cause a warning:
/* :focus with outline: 0 and provides replacement treatment */
a:focus {
border: 1px solid red;
outline: 0;
}