How to set text in html so that it cannot be selected

藏色散人
Release: 2021-11-10 14:24:32
Original
6905 people have browsed it

htmlHow to set text that cannot be selected: 1. Create an HTML page file; 2. Set the css style to "user-seletct: none;-webkit-user-seletct: none;-moz-user-seletct : none;" will do.

How to set text in html so that it cannot be selected

The operating environment of this article: windows7 system, HTML5 version, DELL G3 computer

html How to set text so that it cannot be selected?

Methods to control the content of HTML pages that cannot be selected

There are two methods

One: css method

user-seletct: none;
-webkit-user-seletct: none;
-moz-user-seletct: none;
-ms-user-seletct: none;
Copy after login

none: The content cannot be selected

text: Content can be selected

2: js method

document.body.onselectstart = function(){
  return false;
}
Copy after login

returns false, cannot be selected

returns true, can be selected

Recommended learning : "HTML5 video tutorial"

The above is the detailed content of How to set text in html so that it cannot be selected. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!