
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML Tag
The <head> tag in HTML works as a container for the following elements − <title>, <style>, <base>, <link>, <meta>, <script>, <noscript>.
In HTML5, you can even work with an HTML document without including the <head> element.
<title> inside <head>
Let us now see an example to implement the <head> tag and add <title> −
Example
<!DOCTYPE html> <html> <head> <title>Document Title</title> </head> <body> <h2>Demo Heading</h2> <p>This is demo text.</p> <p>This is demo text.</p> <p>This is demo text.</p> <p>This is demo text.</p> </body> </html>
This will produce the following output displaying the title of the document we added under the <head> element −
<base> inside <head>
The base tag in HTML is used to set the base URL for an HTML document. The <head> works as a container for <base> element as well. For example, base URL as https −//example.com/tutorials for all the relative URLs like /html, /java, /jquery etc., which are eventually −
https −//example.com/tutorials/html https −//example.com/tutorials/java https −//example.com/tutorials/jquery
Note − The <base> tag has no end tag i.e. no need to end it with </base>
Following are the attributes −
- href − It sets the base URL for all relative URLs in the page
- target − Default target for all hyperlinks and forms. The values can be _blank, _parent, _self, _top and framename .
Let us now see an example to implement the <base> element −
Example
<!DOCTYPE html> <html> <head> <base href="https −//www.example.com/tutorials/"> </head> <body> <h2>Tutotials List</h2> <p><a href="java.html">Java Tutorial</a></p><p>(This will act as https −//www.example.com/tutorials/java.html)</p> <p><a href="jquery.html">jQuery Tutorial</a></p><p>(This will act as https −//www.example.com/tutorials/jquery.html)</p> <p><a href="blockchain.html">Blockchain Tutorial</a></p><p>(This will act as https −//www.example.com/tutorials/blockchain.html)</p> <p><a href="python.html">Python Tutorial</a></p><p>(This will act as https −//www.example.com/tutorials/python.html)</p> </body> </html>
Output
- Related Articles
- Why do we use head tag in HTML Page?
- Should I always put my JavaScript file in the head tag of my HTML file?
- HTML Tag
- HTML Tag
- HTML Tag
- HTML Tag
- HTML Tag
- HTML Tag
- HTML Tag
- HTML Tag
- HTML Tag
- HTML Tag
- HTML Tag
- HTML tag
- HTML Tag
