Re: UA's implementation of ::selection

On May 15, 2010, at 9:48 AM, David Hyatt wrote:

> Selection would work much better if it was a property that was just part of the cascade and inherited by default, e.g.,
> 
> #mydiv {
>   selection: green;
> }

This would be a good, simple approach. It should take at least two values though (foreground and background color). It would work well if we wanted to limit the styling to just color (and not background-images, shadow, etc.).


> Or if we want to have more flexibility for extensibility, you could use some kind of identifier reference to point to an external rule:
> 
> @selection myselection {
>   background-color: green;
> }
> 
> #mydiv {
>   selection: myselection;
> }

Does that get us into the endless debates like we had when discussing @variable or @constant or @macro or whatever?

> Alternatively we could say ::selection is only queried against the root element, and then have the pseudo element itself take an argument identifier:
> 
> html::selection(myselection) {
>   background-color: green
> }|
> 
> #mydiv {
>   selection: myselection;
> }

I like that approach, especially if we want to expand beyond just the two color properties, and allow text-shadow, box-shadow (if it was one selection shape even when spanning multiple elements), outline, border, etc. 

If it was not per element at all, something similar might also seem to be more appropriate as a way to describe what iPhone selection is like, sitting in front of the whole page:

html::selection {
  -css4-background-color: blue multiply;
  border-left:1px solid bue;
  border-right:1px solid bue;
}

Received on Saturday, 15 May 2010 19:51:05 UTC