<base> Tag in HTML

The <base> tag in HTML specifies the base URL for all relative URLs in a document. It is typically used in the <head> section to define a reference point for all relative links (like images, hyperlinks, and other resources).

Key Points on <base> Tag:

Syntax of <base> Tag:

Syntax Example

<base href="https://www.example.com/" target="_blank">

Example of <base> Tag in HTML:

This example demonstrates how to use the <base> tag to define a base URL for relative links.

Code Example


<html>
<head>
    <base href="https://www.example.com/" target="_blank">
</head>
<body>
    <a href="{{ url_for('render_dynamic_template', template_name='about') }}">About Us</a>
    <a href="{{ url_for('render_dynamic_template', template_name='contact') }}">Contact Us</a>
</body>
</html>
    

The <base> tag simplifies the management of relative URLs by setting a base path for all relative links. It is especially useful when the document is referenced from different locations or servers.