Files
30-seconds-of-code/snippets/disable-selection.md
2019-08-22 12:30:43 +03:00

39 lines
633 B
Markdown

---
title: Disable selection
tags: interactivity,intermediate
---
Makes the content unselectable.
#### HTML
```html
<p>You can select me.</p>
<p class="unselectable">You can't select me!</p>
```
#### CSS
```css
.unselectable {
user-select: none;
}
```
#### Demo
#### Explanation
`user-select: none` specifies that the text cannot be selected.
#### Browser support
<span class="snippet__support-note">⚠️ Requires prefixes for full support.</span>
<br>
<span class="snippet__support-note">⚠️ This is not a secure method to prevent users from copying content.</span>
- https://caniuse.com/#feat=user-select-none