Home > Article > Web Front-end > What is the usage of select in css3
In CSS3, select is used to specify whether the text of an element can be selected in the "user-select" attribute; this attribute can prevent the behavior of double-clicking to select text in the browser. By default, this attribute is allowed To select element text, the syntax is "element {user-select: attribute value;}".
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
The user-select attribute specifies whether the text of the element can be selected.
In a web browser, if you double-click on text, the text will be selected or highlighted. This property is used to prevent this behavior.
Default value: auto
The syntax is:
user-select: auto|none|text|all;
The attribute value represents the result as follows:
auto Default. Text can be selected if the browser allows it.
none Prevents text selection.
text Text can be selected by the user.
all Click to select text, rather than double-clicking.
The example is as follows:
<!DOCTYPE html> <html> <head> <style> div { -webkit-user-select: none; /* Safari */ -ms-user-select: none; /* IE 10 and IE 11 */ user-select: none; /* Standard syntax */ } </style> </head> <body> <h1>user-select 属性</h1> <div>The text of this div element cannot be selected. If you double-click me, my text will not be highlighted.</div> </body> </html>
Output result:
(Learning video sharing: css video Tutorial)
The above is the detailed content of What is the usage of select in css3. For more information, please follow other related articles on the PHP Chinese website!