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>
相關文章
相關標籤/搜索