[Solved] I would like to make separate html files containing css and javascript * .html, * .js and * .css


It doesn’t work because the javascript is loaded and executed while the page loads and mounts. So the DOM objects you are trying to use don’t yet exist.

What you have to do? You have to run this code right after the page loads. You can do this by adding onload event in body tag.

<head>
    <title>Odštevanje do Novega Leta</title>
</head>
<body onload="startTimer();">

Or you can do this way in javascript

window.onload=function(){
  startTimer();
}

Tip: To check if something is wrong with your code, use the browser inspector.

1

solved I would like to make separate html files containing css and javascript * .html, * .js and * .css