Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions files/en-us/web/css/_colon_focus-visible/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,32 @@ input, button {
A custom control, such as a custom element button, can use `:focus-visible` to selectively apply a focus indicator only on keyboard-focus. This matches the native focus behavior for controls like {{htmlelement("button")}}.

```html
<custom-button tabindex="0" role="button">Click Me</custom-button>
<button class="custom-button">Click Me</button>
```

```css
custom-button {
.custom-button {
display: inline-block;
margin: 10px;
}

custom-button:focus {
.custom-button:focus {
/* Provide a fallback style for browsers
that don't support :focus-visible */
outline: 2px solid red;
background: lightgrey;
}

@supports selector(:focus-visible) {
custom-button:focus {
.custom-button:focus {
/* Remove the focus indicator on mouse-focus for browsers
that do support :focus-visible */
outline: none;
background: transparent;
}
}

custom-button:focus-visible {
.custom-button:focus-visible {
/* Draw a very noticeable focus style for
keyboard-focus on browsers that do support
:focus-visible */
Expand Down