开发者

How to get the effect of 'user-select: text' in css3?

The validator at http://jigsaw.w3.org/css-validator/ says that the value 'text' for 'user-select' is not valid. For a css rule with this code in it:

   user-select: text;
  • the validator says:

    text is not a user-select value : text text

Presumably this is because of this behavior, specified at (the outdated) http://www.w3.org/TR/2000/WD-css3-userint-20000216#user-select:

This property is not inherited, but it does affect children in the same way that display: none does, it limits it. That is if an element is user-select: none, it doesn't matter what the user-select value is of its children, the element's contents or it's childrens contents cannot be selected.

Also, I only see the attribute value 'text' specified in that out-of-date css3 开发者_运维技巧doc from w3.org:

http://www.w3.org/TR/2000/WD-css3-userint-20000216#user-select

and not in the latest one: http://www.w3.org/TR/css3-ui/

Additionally, searching 'whatwg.org' yields nothing.

Any ideas if 'user-select: text' is valid css3, and if not, what should be used instead?

This would be used, for example, when overriding 'user-select: none' rules applied to containers of text and ancestor containers.


You are getting this wrong. user-select:text doesn't mean it would select text only. It's default value of user-select property. W3C describe it this way:

The element's contents follow a standard text content selection model.

And Also MDN syas something same:

-moz-none The text of the element and sub-elements cannot be selected, but selection can be enabled on sub-elements using -moz-user-select:text .

So I don't think this should prevent selecting images or boxes. As far as I know user-select:text is useful when you have user-select:none for most or all of your elements and you have a textbox or text area that is kind of output and you want it be selectable for copying and pasting.

It seems if you use -webkit- prefix it works for me. I'm sure it works with -moz- prefix too. Test this fiddle in your browser. I don't know why user-select:text is not working on my Chrome 13 Mac?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜