How Can I Make HTML Elements Unhighlightable? [duplicate]
Asked Answered
C

2

12

I'm trying to make it so certain text and images on an HTML page cannot be highlighted with the cursor, so it appears as if they're a part of the background.

Claudiaclaudian answered 23/9, 2009 at 5:4 Comment(0)
D
6

Is there a way to make text unselectable on an HTML page?

Dartmoor answered 23/9, 2009 at 5:8 Comment(1)
Thanks! I searched but didn't find that in the results since it used "unselectable" instead of "unhighlightable".Claudiaclaudian
B
3

First of all if I would like to know the intention behind this. If this is to prevent the user from copying your text and images then I think its impossible for you to make this happen. Once it is rendered to the client browser area then the whole thing comes under the control of the user.

For images not to be highlighted make them as background.

You can also place a transparent div on top of the area where you don't want the selection to occur. Position the div so that they will appear on top of the element with a higher stacking order. For a greater stacking order you can use the z-index property.

Bowls answered 23/9, 2009 at 5:6 Comment(1)
Once it is rendered to the client browser area then the whole thing comes under the control of the user. Just to additionally clarify... If it's hosted on your website, and there is no authentication necessary to retrieve it, it can be found, and it can be downloaded. Even if you never link to an image anywhere, or use it in a webpage, or put it in an obvious place. If you can get to it over the internet without authentication, anyone can. The only caveat to that would be if you used strong encryption in combination with strong steganography. But even then be careful.Depicture

© 2022 - 2024 — McMap. All rights reserved.