HTML base 标签
htmlweb developmentfront end technology更新于 2025/3/20 9:16:17
HTML 中的 base 标签用于设置 HTML 文档的 base URL。例如,所有相对 URL(例如 /html、/java、/jquery 等)的 base URL 都应为 https://example.com/tutorials,这些 URL 最终 −
https://example.com/tutorials/html https://example.com/tutorials/java https://example.com/tutorials/jquery
注意:<base> 标签没有结束标签,即无需以 </base> 结尾。
以下是 − 属性。
- href:设置页面中所有相对 URL 的基准 URL。
- target:所有超链接和表单的默认目标。其值可以是 _blank、_parent、_self、_top 和 framename。
现在让我们看一个实现 <base> 元素的示例。−
示例
<!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>
输出

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

