Base标签

mac2022-06-30  27

BASE

base标签为页面上所有的相对链接设置默认URL或默认目标.

在一个文档中,最多能使用一个base元素.base标签必须位于head元素内部.

提示和注释

提示:请把base标签排在head元素中第一个元素的位置,这样 head 区域中其他元素就可以使用base元素中的信息了。

注释:如果使用了base标签,则必须具备 href 属性或者 target 属性或者两个属性都具备.

base属性值

属性值描述hrefurl规定页面中所有相对链接的基准 URLtarget_blank,_parent,_self,_top,framename规定页面中所有的超链接和表单在何处打开.该属性会被每个链接中的 target 属性覆盖

target属性值

属性描述_blank在新窗口中打开被链接文档_self默认.在相同的框架中打开被链接文档_parent在父框架集中打开被链接文档_top在整个窗口中打开被链接文档framename在指定的框架中打开被链接文档

实例

<!DOCTYPE html> <html lang="en"> <head> <base href="https://www.baidu.com" target="_top"></base> <meta charset="UTF-8"> <title>Document</title> </head> <body> <img src="img/bd_logo1.png"> </body> </html>

转载于:https://www.cnblogs.com/masai1969/p/4351443.html

最新回复(0)