Bada
Bada's Coding

Bada's Coding

<base>

Bada's photo
Bada
·Oct 8, 2022·

1 min read

What Does It Do?

It is used to set default URL for other tags.

<head>
  <base href="https://example.com/" />
</head>
<body>
  <a href="path?query=value">link</a>
</body>

target="_blank"

If it is written, the link opens in a new tab.

<head>
  <base href="https://example.com/" target="_blank" />
</head>
<body>
  <a href="path?query=value">link</a>
</body>

<link> and <script>

These tags are also affected by <base>. So, be careful when you import css or js files.

<head>
  <base href="https://example.com/" />
  <!-- Local 'style.css' is not going to be applied. -->
  <link rel="stylesheet" href="style.css" />
  <!-- Local 'script.js' is not going to be applied. -->
  <script src="script.js"></script>
</head>
 
Share this