
- 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 href Attribute
The href attribute of the <base> element sets the base URL for all relative URLs. 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
Following is the syntax −
<base href="absolute_URL">
Above, absolute _URL is the absolute url for the base URL. Let us now see an example to implement the href attribute of the <base> element −
Example
<!DOCTYPE html> <html> <head> <base href="https://www.example.com/tutorials/"> </head> <body> <h2>Tutorials 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
In the above example, we have set the base URL as −
<base href="https://www.example.com/tutorials/">
After the we mentioned the link as "java.html", that would eventually act as −
https://www.example.com/tutorials/java.html
- Related Articles
- HTML href Attribute
- HTML href Attribute
- HTML href Attribute
- How to use href attribute in HTML Page?
- HTML DOM Anchor href Property
- HTML DOM Link href Property
- HTML DOM Location href Property
- HTML DOM Base href Property
- How to change the href attribute for a hyperlink using jQuery?
- HTML maxlength Attribute
- HTML wrap Attribute
- HTML checked Attribute
- HTML datetime Attribute
- HTML value Attribute
- HTML coords Attribute

Advertisements