# .blur()

> The `.blur()` JS browser API method removes keyboard focus from the specified element.

## How do I remove focus from an element in JavaScript?

The browser API method that removes focus from an element, like an input field. It's often used to indicate that the user has finished interacting with the element.

- Topic: Object on Page
- Type: method
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1.5+, Firefox Android 4+, Safari 3+, Safari iOS 1+

## Example

Wrong:

```js
menuItem.addEventListener('click', () => {
  closeMenu();
  menuItem.blur();
});
```

Right:

```js
menuItem.addEventListener('click', () => {
  closeMenu();
  menuTrigger.focus();
});
```

Blurring drops focus to the body, so keyboard users lose their place; move focus to a meaningful element.

## Common mistakes

- Calling `blur()` after a click to hide the outline, which breaks keyboard navigation.
- Expecting the `blur` event to bubble for delegation; `focusout` does.

## Key points

- Focus is moved to a meaningful element with `focus()` instead of being dropped with `blur()`.
- Focus rings are not hidden by calling `blur()` on click; `:focus-visible` styling is used instead.

## Interview questions

### blur vs focusout?

Both fire when an element loses focus, but `focusout` bubbles and `blur` does not, so event delegation needs `focusout`.

### Where does focus go after blur()?

To the document body: `document.activeElement` becomes `document.body`.

### How do I hide the focus ring on mouse click?

Style `:focus-visible` instead of `:focus`. Browsers usually skip the ring for mouse clicks on buttons and keep it for keyboard users.

## Related cards

- [.focus()](https://wonderium.dev/js/focus.md)
- [:focus-visible](https://wonderium.dev/css/focus-visible.md)
- [:focus](https://wonderium.dev/css/focus.md)
- [Focus Appearance](https://wonderium.dev/a11y/focus-appearance.md)
- [Event](https://wonderium.dev/js/event.md)

---

- Level: [JavaScript](https://wonderium.dev/js.md)
- HTML version: https://wonderium.dev/js/blur
- Last updated: 2026-11-25
