I'm new to HTML, CSS and JavaScript, and I've stumbled upon a problem. This code should create a picture that's moving to the right over time, but it only works if I delete the doctype line of code. I've tried this code in the validator, it shows no errors, but it doesn't do what I want it to do unless I delete the doctype. What should I change here?
<!doctype html>
<html>
<head>
<title>Timer pomeranje</title>
<script>
var the_timer, x_position = 0, the_image;
function set_timer() {
the_image = document.getElementById("djuro_image");
x_position = x_position + 1;
the_image.style.left=x_position;
the_timer = setTimeout(set_timer, 50);
}
</script>
</head>
<body onload = "set_timer()">
<img src = "Djuro.png" id = "djuro_image" style = "position:absolute; left:0px" alt = "Djuro">
</body>
</html>