Styles and scripts can be placed directly in the head
of the document or even inline with the element they are modifying, but neither are good practice. It would be better to link to external scripts and/or style sheets.
However, if you must place them in the document itself, the following shows where we want to place our script(s) and style(s). Typically this is done directly after the title
tag.
The style
tag is used to enclose all the styles we want to place in the head
of our document. Style chunks like this can only be placed in the head
of the document.
Similarly, the script
tag is used to enclose all our scripts. Typically they are placed in the head
of the document, but can be placed anywhere in the head
or even body
of the document if necessary.
Advanced HTML Template
Placing a Script in the Body
Scripts can also be placed just before the closing /body
tag which can speed up the page load time because the page can first render before applying the scripts.