Skip to content

Proposal: Allow adding separator rows to <select> boxes using <hr> #3410

@a2sheppy

Description

@a2sheppy

There is no standard way to create a proper separator or dividing line within the box created using <select>. Currently, the most common solution is to just put some hyphens or emdashes in an <option> with the disabled attribute set. This doesn't actually look very good at all, and is not semantically accurate.

There's already a perfectly good element for creating horizontal dividing lines in HTML: the <hr> element. This should be allowed in the context of a <select> element in order to create separator rows.

This would let you then create a separator using <hr> within the <select>, like:

<select id="devicelist">
    <option value="none">None</option>
    <hr/>
    <option value="1903177618651917">Internal microphone</option>
</select>

In this situation, the <hr> is interpreted as a separator row and treated as such, rather than as a selectable option (since it's not an <option> element.

I've also filed this on the W3C spec: w3c/html#1156

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions