Where should I put the CSS and Javascript code in an HTML webpage?

In my opinion the best practice is to place the CSS file in the header

<head>
  <link rel="stylesheet" href="https://stackoverflow.com/questions/6625773/css/layout.css" type="text/css">
</head>

and the Javascript file before the closing </body> tag

  <script type="text/javascript" src="https://stackoverflow.com/questions/6625773/script.js"></script>
</body>

Also if you have, like you said two CSS files. The browser would use both. If there were any selectors, ie. .content {} that were the same in both CSS files the browser would overwrite the similar properties of the first one with the second one’s properties. If that makes sense.

Leave a Comment