W3C home > Mailing lists > Public > public-css-archive@w3.org > May 2017

Re: [csswg-drafts] [selectors] :read-only and :read-write

From: Stuart Ballard via GitHub <sysbot+gh@w3.org>
Date: Mon, 01 May 2017 13:51:56 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-298336701-1493646714-sysbot+gh@w3.org>
>From my (admittedly HTML-centric) perspective as a web developer using CSS, there's a definite use case for these pseudo-classes, but changing their meaning slightly would make them far more useful.

I see them as useful to allow a selector to [match all text entry elements in HTML](http://stackoverflow.com/questions/16333957/css-selector-for-general-textboxes), which is otherwise not possible. The linked article can only suggest variations on this fundamentally flawed approach:

```css
input:not([type]), /* all non-declared types */
input[size], /* text, search, tel, url email, or password */
input[type^=date], /* date, datetime, datetime-local */
input[type=color],
input[type=week],
input[type=month],
input[type=time],
input[type=number],
input[type=range] {
   /* styles */
}
```

This approach is problematic in many ways:

- It's unnecessarily clumsy and verbose.
- It presumes that the `size` attribute will be specified on all text inputs, which may not be the case.
- It is fundamentally tied to a specific user-agent - in fact, to a specific *version* of a specific user-agent - because user agents are rightly given free rein regarding the UI they present for the different `<input>` types, and do in fact make different choices from vendor to vendor and version to version.
- It cannot account for new `<input>` types that may be added to the HTML specification in the future

As currently specified, the `:read-write` pseudo gets partway to meeting this need, but does not offer a way to match readonly (other than a `[readonly]` attribute selector) or disabled text inputs because `:read-only` is defined too broadly.

I would suggest changing the specification of `:read-only` to match only elements that *could* support `:read-write` but are currently readonly or disabled.

-- 
GitHub Notification of comment by sab39
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/127#issuecomment-298336701 using your GitHub account
Received on Monday, 1 May 2017 13:52:03 UTC

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 10:12:53 UTC