The HTML <script> Element
The <script> element is employed to declare client-side JavaScripts.
The subsequent JavaScript code writes “Hello JavaScript!” into an HTML element identified by id=”demo”:
Example
<script> function myFunction() { document.getElementById(“demo”).innerHTML = “Hello JavaScript!”; } </script> |
The HTML <base> Element
The <base> element defines the base URL and/or target for all relative URLs within a page.
The <base> tag must contain either an href attribute, a target attribute, or both.
A document can contain only a single <base> element.
Example
Define a default URL and target for all links within a page:
<head> <base href=”https://www.code7school.com/” target=”_blank”> </head>
<body> <img src=”images/stickman.gif” width=”24″ height=”39″ alt=”Stickman”> <a href=”tags/tag_base.asp”>HTML base Tag</a> </body> |
Summary of the Chapter
- The <head> element serves as a repository for metadata, which provides information about the data within the document.
- Positioned between the <html> and <body> tags, the <head> element is crucial.
- The <title> element is obligatory, defining the document’s title.
- For a single document, the <style> element is utilized to articulate style information.
- Primarily, the <link> tag is employed to connect with external style sheets.
- Typically, the <meta> element is used to designate the character set, page description, keywords, authorship of the document, and viewport settings.
- To specify client-side JavaScripts, the <script> element is utilized.
- The <base> element defines the base URL and/or target for all relative URLs within a page.