CSS :default Selector

Beginner
⏱️ 6 min read
📚 Updated: Jul 2026
🎯 4 Examples
Form States

What You’ll Learn

The :default pseudo-class styles form elements that are the default choice in their group — the option pre-selected in your HTML when the page loads.

01

Default state

Pre-selected.

02

Radio

checked attr.

03

Select

selected option.

04

Checkbox

Default on.

05

vs :checked

Initial vs now.

06

UX hint

Show defaults.

Introduction

The :default selector in CSS is a pseudo-class used to target form elements that are the default in a group of related controls. It highlights what the author set as the initial choice in the HTML markup.

This applies to radio buttons and checkboxes with the checked attribute, <option> elements with selected inside a <select>, and the default submit button in a form.

Definition and Usage

Append :default to a selector with no space before the colon: input:default or option:default. Styles apply to elements that represent the default state — including what would be restored if the user resets the form.

💡
Beginner Tip

:default and :checked often match the same element on page load. The difference appears after interaction: :checked follows the user’s current choice, while :default always refers to the originally default element in the HTML.

📝 Syntax

The syntax for the :default pseudo-class is:

syntax.css
element:default {
  /* CSS properties */
}

Basic Example

default-form.css
input[type="radio"]:default {
  outline: 2px solid #2563eb;
  accent-color: #2563eb;
}

option:default {
  font-weight: 700;
  color: #1d4ed8;
}

Syntax Rules

  • Only form elements with a defined default state can match :default.
  • Use checked on radios/checkboxes and selected on options in HTML.
  • Combine with type selectors: input[type="radio"]:default.
  • Pair with + label to style the label of a default radio button.
  • Not for text inputs, textareas, or elements without a default group role.

Related Selectors

  • :checked — matches the currently selected/checked element
  • :disabled — matches form controls that cannot be interacted with
  • :optional and :required — validation state selectors
  • [checked] and [selected] — attribute selectors for defaults

⚡ Quick Reference

QuestionAnswer
Selector typePseudo-class
When it appliesElement is the default in its form control group
Common targetsradio, checkbox, option, default submit
HTML attributeschecked, selected
vs :checked:default = initial HTML default; :checked = current selection
Browser supportAll modern browsers
input:default input[type="radio"]:default option:default input:default + label

When to Use :default

:default helps users spot the recommended or pre-selected choice:

  • Settings forms — Highlight the recommended plan or contact method on load.
  • Country/locale selects — Emphasize the default region in a dropdown.
  • Opt-in checkboxes — Show which newsletter options start checked by default.
  • Reset behavior — Style elements that would be restored when a form is reset.
  • Onboarding — Visually distinguish factory defaults from user-changed values.

👀 Live Preview

The Email radio (with checked) matches :default and gets a blue outline. Phone does not:

Choose contact method:

Examples Gallery

Practice :default with radio buttons, select options, checkboxes, and comparison with :checked.

📜 Core Patterns

Highlight pre-selected form controls defined in HTML.

Example 1 — Default radio button

Style the radio button marked with checked as the default contact method.

radio-default.css
input[type="radio"]:default {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  accent-color: #2563eb;
}

input[type="radio"]:default + label {
  color: #1d4ed8;
  font-weight: 700;
}
Try It Yourself

How It Works

Only the radio with checked in the HTML matches :default. The label beside it is styled via the adjacent sibling combinator.

Example 2 — Default select option

Target the option with selected using option:default.

option-default.css
option:default {
  font-weight: 700;
  color: #1d4ed8;
}
Try It Yourself

How It Works

The selected attribute marks the default option. Note that browsers limit how option elements can be styled — test in your target browsers.

📄 Comparison Patterns

Distinguish default markup from current user selection.

Example 3 — Default checkbox

Highlight a checkbox that starts checked by default in the HTML.

checkbox-default.css
input[type="checkbox"]:default {
  outline: 2px solid #16a34a;
  outline-offset: 2px;
  accent-color: #16a34a;
}
Try It Yourself

How It Works

Only the checkbox with checked in the markup matches :default. Useful for showing which preferences are enabled by default.

Example 4 — :default vs :checked

Compare the initial HTML default with the user’s current selection after they interact with the form.

default-vs-checked.css
/* Original default from HTML */
input[type="radio"]:default + label {
  color: #1d4ed8;
}

/* Currently selected option */
input[type="radio"]:checked + label {
  text-decoration: underline;
}
Try It Yourself

How It Works

On load, both match Email. If the user selects Phone, :checked moves to Phone but :default still matches Email because that was the HTML default.

⚠️ Common Pitfalls

  • Limited elements:default does not apply to text inputs, textareas, or plain divs.
  • Confusing with :checked — On page load they often overlap; after user interaction they diverge.
  • Missing attributes — Without checked or selected in HTML, no element matches :default.
  • option styling — Browsers restrict styling of <option> elements; visual changes may be subtle.
  • Over-highlighting — Don’t rely only on color to indicate defaults; add text like “(recommended)” when helpful.

♿ Accessibility

  • Labels required — Always pair inputs with <label for="id"> so screen reader users know what each default option means.
  • Don’t rely on style alone — Supplement :default styling with clear text indicating the recommended choice.
  • Pre-selected opt-ins — Be careful with checked-by-default marketing checkboxes; some regulations require explicit consent.
  • Focus styles — Style :focus alongside :default for keyboard users navigating the form.

🧠 How :default Works

1

Author sets defaults in HTML

You add checked or selected to mark the default choice.

HTML
2

Page loads

The browser identifies which control is the default in each group.

Parse
3

:default styles apply

CSS rules for :default highlight the pre-selected elements.

Render
=

Clear default choices

Users can quickly see which options are recommended or pre-selected.

Browser Compatibility

The :default pseudo-class is supported in all modern browsers. Option styling may vary by platform.

Modern browsers · Full support

Default form styling in modern CSS

:default works in Chrome, Firefox, Safari, Edge, and Opera.

97% Browser support
Google Chrome 10+ · Desktop & Mobile
Full support
Mozilla Firefox 4+ · Desktop & Mobile
Full support
Apple Safari 5+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 10.5+ · All versions
Full support
:default pseudo-class 97% supported

Bottom line: :default is reliable for modern form UIs; use :checked when you need the current selection regardless of HTML defaults.

Conclusion

The :default pseudo-class lets you style form elements that are pre-selected in your HTML. It is a useful complement to :checked when you want to highlight the author’s recommended or factory-default choices.

Use it on radio buttons, checkboxes, and select options to improve form clarity. Pair visual styling with accessible labels and clear text so every user understands the default selections.

💡 Best Practices

✅ Do

  • Use input[type="radio"]:default for specificity
  • Mark defaults with checked and selected in HTML
  • Combine with labels via input:default + label
  • Explain defaults with text like “(recommended)”
  • Use :checked for current selection feedback

❌ Don’t

  • Apply :default to non-form elements
  • Assume it always equals :checked after user input
  • Rely only on color to show default options
  • Pre-check consent boxes without legal review
  • Expect full option styling in every browser

Key Takeaways

Knowledge Unlocked

Five things to remember about :default

Use these points when styling default form controls.

5
Core concepts
🔴 02

Radio

checked attr.

Input
03

Option

selected attr.

Select
04

vs :checked

Initial vs now.

Compare
🌐 05

97% support

Modern browsers.

Compat

❓ Frequently Asked Questions

The :default pseudo-class matches form elements that are the default choice in their group — such as a radio button with the checked attribute, an option with selected, or the default submit button in a form.
input[type="checkbox"], input[type="radio"], option elements inside select, and submit/button inputs that serve as the default action in a form.
:default matches the element marked as the initial default in HTML. :checked matches whichever option is currently selected. After a user picks a different radio button, :checked moves but :default stays on the originally default element.
Yes. Use option:default to target the option with the selected attribute. Browser styling support for options can vary, so test in your target browsers.
Yes in all modern browsers. Chrome, Firefox, Safari, and Edge support :default. It is less common than :checked but safe for modern projects.

Practice in the Live Editor

Open the HTML editor and experiment with :default, option:default, and comparison with :checked.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful