HTML --头部元素

<head>元素是全部头部元素的容器,<head>内的元素能够指示浏览器在何处能够找到样式表,提供一些信息等。head内经常使用的元素有<title>、<base>、<link>、<meta>、<script>及<style>。javascript

1.<title>标签订义文档的标题css

title元素在全部的HTML文档中都是必须的,它定义浏览器地址栏中显示的标题,实例以下html

<!DOCTYPE html>
<html>
<head>
    <title> This is my HTML</title>
</head >
</html>

2.<base>标签为页面上全部连接规定默认地址或默认目标(target)java

<!DOCTYPE html>
<html>
<head>
    <title> This is my HTML</title>
    <!-- 规定默认地址-->
    <base href="http://www.baidu.com"></base>
    <!-- 规定默认目标-->
    <base target="_blank"></base>
</head >
</html>

3.<link>标签订义文档与外部资源之间的联系,它最经常使用于链接样式表浏览器

<!DOCTYPE html>
<html>
<head>
    <title> This is my HTML</title>
    <!-- 规定默认地址-->
    <base href="http://www.baidu.com"></base>
    <!-- 规定默认目标-->
    <base target="_blank"></base>
    <!-- 链接样式表-->
    <link rel="stylesheet" type="text/css" href="mystyle.css">
</head >
</html>

4.<meta>元素经常使用于描述页面功能、关键词、文档做者、建立时间等以及一些其余信息。测试

<!DOCTYPE html>
<html>
<head>
    <title> This is my HTML</title>
    <!-- 规定默认地址-->
    <base href="http://www.baidu.com"></base>
    <!-- 规定默认目标-->
    <base target="_blank"></base>
    <!-- 链接样式表-->
    <link rel="stylesheet" type="text/css" href="mystyle.css">
    <!-- 向浏览器传送信息,告诉浏览器这个文档的字符集类型-->
    <meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
    <!-- 文档做者-->
    <meta name="author" content="LiXianLi">
    <!--修订时间-->
    <meta name="revised" content="panda,12/10/2015">
</head >
</html>

5.<script>标签用于定义客户端脚本ui

<!DOCTYPE html>
<html>
<head>
    <title> This is my HTML</title>
    <!-- 规定默认地址-->
    <base href="http://www.baidu.com"></base>
    <!-- 规定默认目标-->
    <base target="_blank"></base>
    <!-- 链接样式表-->
    <link rel="stylesheet" type="text/css" href="mystyle.css">
    <!-- 向浏览器传送信息,告诉浏览器这个文档的字符集类型-->
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <!-- 文档做者-->
    <meta name="author" content="LiXianLi">
    <!--修订时间-->
    <meta name="revised" content="panda,12/10/2015">
</head >
<body>
    <script type="text/javascript">
        document.write("hello world")
    </script>
</body>
</html>

6.<style>标签用于为HTML文档定义样式信息code

<!DOCTYPE html>
<html>
<head>
    <title> This is my HTML</title>
    <!-- 规定默认地址-->
    <base href="http://www.baidu.com"></base>
    <!-- 规定默认目标-->
    <base target="_blank"></base>
    <!-- 链接样式表-->
    <link rel="stylesheet" type="text/css" href="mystyle.css">
    <!-- 向浏览器传送信息,告诉浏览器这个文档的字符集类型-->
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <!-- 文档做者-->
    <meta name="author" content="LiXianLi">
    <!--修订时间-->
    <meta name="revised" content="panda,12/10/2015">
    <!-- 定义样式信息-->
    <style type="text/css">
    body {background-color: green}
    p {color: blue}
    </style>
</head >
<body>
    <script type="text/javascript">
        document.write("hello world")
    </script>
    <p>测试脚本</p>
</body>
</html>
相关文章
相关标签/搜索