The script tag in HTML is used to embed or reference external JavaScript code within the HTML document. The script element either contains scripting statements or it points to an external script file through the “src” attribute. It is placed within the head tags or the body tags of the HTML document.