CSS Form Control Styling Level 1

W3C First Public Working Draft,

More details about this document
This version:
https://www.w3.org/TR/2025/WD-css-forms-1-20250325/
Latest published version:
https://www.w3.org/TR/css-forms-1/
Editor's Draft:
https://drafts.csswg.org/css-forms-1/
History:
https://www.w3.org/standards/history/css-forms-1/
Feedback:
CSSWG Issues Repository
Inline In Spec
Editor:
(Apple Inc.)
Suggest an Edit for this Spec:
GitHub Editor

Abstract

This CSS Module defines various ways of styling form controls and their different parts.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, etc.

Status of this document

This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C standards and drafts index at https://www.w3.org/TR/.

This document was published by the CSS Working Group as a First Public Working Draft using the Recommendation track. Publication as a First Public Working Draft does not imply endorsement by W3C and its Members.

This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Please send feedback by filing issues in GitHub (preferred), including the spec code “css-forms” in the title, like this: “[css-forms] …summary of comment…”. All issues and comments are archived. Alternately, feedback can be sent to the (archived) public mailing list [email protected].

This document is governed by the 03 November 2023 W3C Process Document.

This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

1. Introduction

This section is non-normative.

User agents have long provided non-standard ways of styling form controls. However, all of these controls are implemented inconsistently across user agents, creating unnecessary friction for authors.

This module aims to define a set of form control parts in enough detail that they can be used interoperably.

It also defines some new ways of customizing form controls, covering common use cases that were previously only possible by implementing custom controls from scratch, which was a lot of work, hard to get right, and often broke either accessibility or platform conventions.

2. Opting Into Basic Appearance: the appearance: base value

Move definition of appearance here.

Name: appearance
New values: base

When applied on a form control, base puts that control in the basic appearance state.

A control that has basic appearance is consistently styleable using standard CSS and the pseudo-elements defined below, and applies overridable default styles that are consistent across UAs. When a control is in that state, the user agent applies styles from the Appendix A: Basic Appearance User Agent Stylesheet to that control.

The user agent must also enable the pseudo-elements defined by § 4 Pseudo-Elements. These pseudo-elements (excluding ::picker()) always inherit appearance from their originating element. The user agent may implement this using an appearance: inherit !important declaration.

NOTE: The inheritance prevents authors from mixing native and non-native parts for the same control.

2.1. Design Principles for the Basic Appearance

The following design principles apply to the design of the basic appearance stylesheet for form controls, in order of descending importance:

  1. The styles are identical in every user agent.

  2. The controls are recognizable and usable on their own without additional styles.

  3. The controls pass 100% of WCAG 2.2 AA standards.

  4. The styles are consistent across controls…

    1. …in look & feel.

    2. …in how they are defined in code.

    3. …in sizing and interaction.

  5. The styles are easily adapted to the website’s branding, without needing complex reset stylesheets:

    1. They use minimal code and are easy to override.

    2. They do not have a strong voice & tone of their own, and are visually as simple as possible.

    3. They inherit page styles rather than define new styles whenever possible.

    4. They are resilient to adjustments…

      1. …when changed themselves (e.g. changing font, border, layout).

      2. …when put in context (e.g. ready to be flex or grid children).

  6. They are comprehensive:

    1. Covering all states for each control.

    2. Supporting all writing modes and color schemes.

For HTML form controls specifically, these principles are applied through the required user agent stylesheet defined in Appendix A: Basic Appearance User Agent Stylesheet.

2.2. Examples

Refine these examples through implementation, experimentation, bikeshedding and improvements to the user agent stylesheet.

The main purpose of these examples is to show how the design principles for the basic appearance apply in practice.

To apply the basic appearance on individual controls, the following code is used:

input, textarea, meter, progress, button, select {
  appearance: base;
}

NOTE: The form layout used by the following examples is not detailed.

2.2.1. Default User Agent Colors

Here are the basic appearance colors inheriting respectively the default light and dark mode colors from the root element:

Screenshot of the basic appearance with a light color scheme Screenshot of the basic appearance with a dark color scheme

2.2.2. Color/Font Customization

Here are some examples of customization being done on top of the basic appearance:

form {
  font-family: "American Typewriter";
  background-color: rgb(254, 252, 221);
  color: rgb(131, 17, 0);
}

input, textarea, meter, progress, button, select {
  appearance: base;
}

Screenshot of a customized basic appearance with brown text and a pale yellow background

form {
  font-family: "Courier New";
  font-size: 14px;
  background-color: rgb(0, 0, 0);
  color: rgb(0, 249, 0);
}

input, textarea, meter, progress, button, select {
  appearance: base;
}

Screenshot of a customized basic appearance with green text and a black background

3. Styling Pickers

3.1. The ::picker() pseudo-element

The ::picker() pseudo-element represents the part of the form control that pops out of the page.

::picker() = ::picker( + )
 = select

The ::picker() pseudo-element only matches when the originating element supports basic appearance and has a popup picker. The specified must also match the unique picker name of the originating element. For example, the unique picker name for the select element is select.

In order for the ::picker() pseudo-element to be rendered, it and its originating element must both have a computed appearance of base.

The following styles apply the basic appearance to the select picker and the select and add some additional styling to the picker:
select, select::picker(select) {
  appearance: base;
}
select::picker(select) {
  border: 5px solid red;
  background-color: blue;
}

NOTE: The non-functional form of ::picker() currently doesn’t work to prevent unintended styling of pickers as new pickers become supported. Once styling for all form control pickers is finalized, this non-functional form will work for all pickers.

4. Pseudo-Elements

Form controls are composed of many parts that authors may want to style separately, hence the need for user agents to provide pseudo-elements for individual form controls.

The section below introduces a set of pseudo-elements that attempts to cover the most common use cases, so they can be addressed in a consistent manner across user agents.

Informative overview of form control pseudo-elements as applied to HTML
Control Pseudo-elements
├─ ''::track''
│  └─ ''::fill''
└─ ''::thumb''
::checkmark
::file-selector-button

See § 4.8 Styling Parts for Date/Time Input Fields: the ::field-component and ::field-separator pseudo-elements

(with no type) See § 4.5 Styling Parts for Text Fields: the ::field-text and ::clear-icon pseudo-elements
See § 4.7 Styling Parts for Number Fields: the ::step-control, ::step-up and ::step-down pseudo-elements
::color-swatch