Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML - Why are Links and Images draggable by default?

I am developing a project and the default drag-drop behaviour is not desirable for me. So instead of writing draggable="false" onto all of my <a> and <img> tags I am using jQuery to set there draggable attributes on ready.

$('a, img').attr('draggable', 'false');

But I also have content that is added dynamically, so again I am calling the function that sets dragging to false when that content is loaded.

My question is, why is this behaviour enabled in the first place? Shouldn't it be the the developers choice to enable dragging or not? - I have been force to go to some lengths to disable dragging, perhaps there is a better solution. Does it contradict the Semantics of HTML to enable behaviour by default? i.e A plain <a href="#"> doesn't describe it as being draggable, but it is.

like image 940
Luke T O'Brien Avatar asked Nov 10 '22 10:11

Luke T O'Brien


1 Answers

Links and Pictures are draggable from default so that you can drag them to a search-bar/browser-tag to only show the image or specific link.

If you want to turn off this default behaviour you can use this css-code: e.g for an img-tag

img
{
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

I haven't used it for links, but it should work too

like image 129
Snickbrack Avatar answered Nov 14 '22 21:11

Snickbrack