Disallow outline:none
Pages 49
-
LoadingHome
-
LoadingAbout
-
LoadingAvoid un anchored hovers
-
LoadingBeware of box model size
-
LoadingBuild System
-
LoadingBuild System Integration
-
LoadingBulletproof font face
-
LoadingCommand line interface
-
LoadingContributing
-
LoadingDeveloper Guide
-
LoadingDisallow !important
-
LoadingDisallow @import
-
LoadingDisallow adjoining classes
-
LoadingDisallow box sizing
-
LoadingDisallow duplicate properties
-
LoadingDisallow empty rules
-
LoadingDisallow IDs in selectors
-
LoadingDisallow negative text indent
-
LoadingDisallow non alphabetical
-
LoadingDisallow outline:none
-
LoadingDisallow overqualified elements
-
LoadingDisallow qualified headings
-
LoadingDisallow star hack
-
LoadingDisallow too many floats
-
LoadingDisallow underscore hack
-
LoadingDisallow units for zero values
-
LoadingDisallow universal selector
-
LoadingDon't use too many web fonts
-
LoadingIDE integration
-
LoadingNew Release
-
LoadingRequire all gradient definitions
-
LoadingRequire fallback colors
-
LoadingRequire shorthand properties
-
LoadingRequire use of known properties
-
LoadingRules
-
LoadingRules by ID
-
LoadingSource Code
-
LoadingUnit Tests
-
LoadingUsing in a Node.js Application
-
LoadingWorking with Rules
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;
}Further Reading
``$ {webkit-tap-highlight-color: rgba(255,255,0,0);}