What is the issue with the HTML Standard?
Description
I would like to propose a new native HTML element: <rating>.
Star ratings and review scores are among the most common UI components on modern e-commerce, media, and booking websites. However, HTML currently lacks a native way to represent or input these values. Developers are forced to build complex workarounds using hidden radio buttons, CSS hacks (~ selectors), or heavy JavaScript components.
A native <rating> element would provide a clean, declarative, and standardized way to handle both read-only scores and interactive inputs without any external code.
Proposed Syntax
<!-- Read-only mode (e.g., product review averages) -->
<rating value="4.3" max="5"></rating>
<!-- Interactive mode for forms -->
<rating name="user-score" value="0" max="5" interactive></rating>
Attributes
value (required): A decimal number representing the current score.
max (optional): The maximum number of stars/points. Defaults to 5.
interactive (optional): A boolean attribute. If present, it allows users to click/tap to change the value (behaving like a form input).
step (optional): Specifies the granularity of the value (e.g., 0.5 for half-stars). Defaults to 1.
Why this is needed (Key Problems Solved)
- Extreme Simplicity: Developers can implement a fully functional star-rating system with a single line of pure HTML, eliminating third-party JS plugins and complex CSS.
- Native Accessibility (A11y): Screen readers struggle with custom star components. A native
<rating> element would automatically expose the correct semantics to the accessibility tree, reading out "Rating: 4.3 out of 5" naturally.
- SEO Optimization: Search engines can immediately index product scores directly from the HTML markup without relying on fragile regex parsing or mandatory JSON-LD boilerplate.
What is the issue with the HTML Standard?
Description
I would like to propose a new native HTML element:
<rating>.Star ratings and review scores are among the most common UI components on modern e-commerce, media, and booking websites. However, HTML currently lacks a native way to represent or input these values. Developers are forced to build complex workarounds using hidden radio buttons, CSS hacks (
~selectors), or heavy JavaScript components.A native
<rating>element would provide a clean, declarative, and standardized way to handle both read-only scores and interactive inputs without any external code.Proposed Syntax
Attributes
value(required): A decimal number representing the current score.max(optional): The maximum number of stars/points. Defaults to5.interactive(optional): A boolean attribute. If present, it allows users to click/tap to change the value (behaving like a form input).step(optional): Specifies the granularity of the value (e.g.,0.5for half-stars). Defaults to1.Why this is needed (Key Problems Solved)
<rating>element would automatically expose the correct semantics to the accessibility tree, reading out "Rating: 4.3 out of 5" naturally.