Keyboard Shortcut to Close Current Tab
In this article
The fastest way to close the current tab in any major browser (Chrome, Firefox, Edge, Safari, Opera, Brave) is Ctrl+W on Windows and Linux, or Cmd+W on Mac. This single shortcut works in nearly every tabbed application, not just browsers—file managers, code editors, and terminal emulators all honor it. If you want to close the current window instead of just the tab, use Ctrl+Shift+W (Windows/Linux) or Cmd+Shift+W (Mac). No setup is required; these shortcuts work by default in all modern browsers.
What You'll Need
- A computer with a keyboard (laptop or desktop).
- A web browser or any tabbed application (Chrome, Firefox, Edge, Safari, etc.).
- At least one open tab to close.
Step-by-Step
- Open a browser window with multiple tabs. The shortcut only makes sense if you have more than one tab; if you close the last tab in a window, the browser may close the entire window (depending on your settings).
- Click on the tab you want to close to make it the active tab. The shortcut always closes the active tab—the one you are currently viewing. If you want to close a different tab, you must click it first.
- Press the shortcut:
- On Windows or Linux: hold down the Ctrl key and press the W key (Ctrl+W).
- On Mac: hold down the Command (⌘) key and press the W key (Cmd+W).
- Release both keys. The tab closes immediately. If you had unsaved form data in that tab (like a half-typed email), you may lose it—see Common Mistakes below.
- To close the entire window (all tabs at once), use Ctrl+Shift+W (Windows/Linux) or Cmd+Shift+W (Mac). This is a separate shortcut; be careful not to press it accidentally.
That's it. The shortcut is universal, so it works in Chrome, Firefox, Edge, Safari, Opera, Brave, and even in many non-browser apps like Visual Studio Code, Notepad++, and Windows File Explorer.
Common Mistakes
- Pressing the wrong key. On Windows, some users press the Windows key instead of Ctrl, which opens the Start menu. On Mac, pressing Option instead of Command does nothing. Double-check your finger placement.
- Closing the wrong tab. The shortcut closes the active tab, not the one your mouse is hovering over. If you have multiple tabs open and you're not looking at the one you want to close, you'll close the wrong one.
- Losing unsaved data. If you're typing in a form, composing an email, or working in an online editor, closing the tab discards all unsaved changes. There's no confirmation dialog in most browsers—the tab just closes.
- Closing the last tab. In some browsers (like Chrome), closing the last tab in a window closes the entire window. If you didn't intend to close the whole window, you'll need to reopen it (Ctrl+Shift+T or Cmd+Shift+T) to restore the tab.
- Using the shortcut in a non-tabbed app. In some applications, Ctrl+W might close a dialog box or even quit the program. Always check what app is in focus before pressing it.
Tips
- Undo a closed tab: If you accidentally close a tab, press Ctrl+Shift+T (Windows/Linux) or Cmd+Shift+T (Mac) to reopen it. This works in all major browsers and even restores the tab's back/forward history.
- Close multiple tabs at once: To close several tabs quickly, hold Ctrl (or Cmd) and click each tab you want to close, then press Ctrl+W (or Cmd+W). Or, right-click a tab and choose "Close other tabs" or "Close tabs to the right."
- Use the mouse alternative: If you prefer the mouse, click the X on the tab itself, or middle-click (click the scroll wheel) on any tab to close it instantly—even if it's not the active tab.
- Customize shortcuts: In some browsers (like Chrome with extensions), you can remap shortcuts, but the default Ctrl+W/Cmd+W is so universal that customizing is rarely needed.
- Learn related shortcuts: Ctrl+Tab switches to the next tab, Ctrl+Shift+Tab goes to the previous tab, and Ctrl+T opens a new tab. These pair well with closing tabs for fast browsing.
Troubleshooting
If the shortcut doesn't work, try these in order:
- Check the active window. Click on the browser window first to make sure it's in focus. If you're typing in a text field, the shortcut might be captured by that field instead of the browser.
- Try the mouse. Click the X on the tab. If that works, the browser is fine—the issue is with the keyboard. Test the Ctrl and W keys individually in a text editor to ensure they're not sticking.
- Restart the browser. A temporary glitch can sometimes prevent shortcuts from working. Save your work, close the browser completely, and reopen it.
- Check for keyboard layout issues. If you're using a non-US keyboard layout, the W key might be in a different position. The shortcut uses the physical key labeled "W," not the letter's position in the layout.
- Update the browser. Outdated browsers may have bugs. Check for updates in the browser's menu (usually under Help > About).
- Disable conflicting extensions. Some browser extensions can intercept keyboard shortcuts. Try disabling extensions temporarily (especially any that manage tabs) and see if the shortcut works.
- Reset browser settings. If nothing else works, resetting the browser to its default settings can fix shortcut issues, but this will remove your extensions and customizations. Make a note of your settings first.
If the shortcut works in one browser but not another, the issue is specific to that browser's settings or extensions.
Frequently Asked Questions
Does Ctrl+W close the entire browser window?
No, Ctrl+W (or Cmd+W) closes only the active tab. If it's the last tab in the window, the window will close as well. To close the entire window with all tabs, use Ctrl+Shift+W (Windows/Linux) or Cmd+Shift+W (Mac).
Can I undo closing a tab?
Yes, press Ctrl+Shift+T (Windows/Linux) or Cmd+Shift+T (Mac) to reopen the last closed tab. You can press it repeatedly to restore multiple tabs in the order they were closed.
Does this shortcut work on mobile browsers?
No, mobile browsers don't have physical keyboards, so this shortcut doesn't apply. On a phone or tablet, you close tabs by tapping the tab switcher button and then tapping the X on each tab.
Why does Ctrl+W sometimes close a dialog box instead of a tab?
In some web apps (like Google Docs), Ctrl+W may close a pop-up dialog or a sub-window first. The shortcut always acts on the focused element. If a dialog is open, it will close that dialog instead of the browser tab.
Is there a way to close a tab without using the keyboard?
Yes, you can click the X on the tab, or middle-click (click the scroll wheel) on any tab to close it. On a laptop trackpad, you can often tap with two fingers or use the right-click menu to close a tab.
Does Ctrl+W work in all browsers equally?
Yes, it's a standard shortcut in Chrome, Firefox, Edge, Safari, Opera, Brave, and most other browsers. It also works in many non-browser apps like file managers and code editors.