html基礎標籤,html標籤

來源:互聯網
上載者:User

html基礎標籤,html標籤
HTML常用標籤

1. <h>  標題

<h1>定義最大標題
<h6>定義最小標題

<h1>this is a heading</h1>

2. <hr/> 水平線
3.注釋

<!-- this is a comment-->

4. <p>   段落

<p>this is a paragraph</p>

5.<br/>  換行
6. style屬性   修改html的樣式
background-color    改變背景顏色
font-family               定義文本字型系列
color                        定義文本顏色
font-size                  定義文本的字型尺寸

text-align                 規定文本水平對齊

<body style="background-color:yellow"><p style="font-family:arial;color:red;font-size:20px;">A paragraph.</p><h1 style="text-align:center">This is a heading</h1>

7.文字格式設定化相關的標籤
粗體文本       <b>
加重語氣       <strong>
定義大號字     <big>
定義為著重文字(不如strong)   <em>
斜體字   <i>
定義小號字   <small>
定義下標字    <sub>
定義上標字   <sup>


8.預格式文本   <pre>
pre元素中的文本通常會保留空格和分行符號,且文本也會顯示等寬字型,故常用來顯示電腦原始碼,注意得使用符號實體表示特殊字元


9.電腦輸出標籤
定義編程代碼       <code> 不會保留多餘的空格和換行
定義變數         <var>
定義鍵盤輸入        <kdb>
定義電腦輸出執行個體        <samp>

10.地址       <address>
<address>定義文檔或文章的作者的聯絡資訊
位於<body>元素內,表示文檔聯絡資訊
位於<article>元素內,表述文章的聯絡資訊


11.縮寫和首字母縮寫
定義縮寫      <abbr>
定義首字母縮寫       <acronym>

<abbr title="etcetera">etc.</abbr><acronym title="World Wide Web">WWW</acronym>

把滑鼠移至縮減詞語上時,title 可用於展示表達的完整版本


12.定義文字方向    <bdo>

<bdo dir="rtl">Here is some Hebrew text</bdo> 從右向左輸出

 

13.區塊引述
定義長的引用     <blockquote>
定義短的引用語    <q>
定義項目      <dfn>
定義著作的標題      <cite>


14.刪除字效果和插入字效果
定義刪除字 <del>
定義插入字 <ins>


15.使用樣式方式
外部樣式表 針對多個頁面

<head><link rel="stylesheet" type="text/css" href="mystyle.css"></head>

內部樣式表 針對單個檔案

<head><style type="text/css">body {background-color: red}p {margin-left: 20px}</style></head>

內聯樣式 針對個別元素

<p style="color: red; margin-left: 20px">This is a paragraph</p>

16.連結 <a>
<a>標籤可以通過href屬性建立指向另一個文檔的連結,也可以通過name屬性建立文檔內的書籤

例:<a href="http://www.w3school.com.cn/">Visit W3School</a>例2:<p><a href="#C4">查看 Chapter 4。</a></p><h2><a name="C4">Chapter 4</a></h2><p>This chapter explains ba bla bla</p>

如果需要在新視窗中開啟連結,則應設定target屬性為"_blank"


17.映像標籤 <img>

例:<img src="boat.gif" alt="Big Boat">

src屬性是圖片位置,alt屬性是設定映像無法載入時的文字顯示


18.表格 <table>
其中行用<tr>定義,列用<td>定義
邊框通過border屬性設定,表頭用<th>屬性設定
表格標題<caption>


19.無序列表 <ul>

<ul><li>Coffee</li><li>Milk</li></ul>

 

20.有序列表 <ol>

<ol><li>Coffee</li><li>Milk</li></ol>

 

21.自訂欄表項 <dl>
其中每個自訂欄表項以<dt>開始,每個自訂欄表項的定義以<dd>開始


22.div元素是為文檔布局,span元素主要用於為部分文本設定樣式屬性


23.架構 <frameset>
垂直架構:
例:

<frameset cols="25%,50%,25%"><frame src="/example/html/frame_a.html"><frame src="/example/html/frame_b.html"><frame src="/example/html/frame_c.html"></frameset>

水平架構:

<frameset rows="25%,50%,25%">

 

24.內聯架構 <iframe>

<iframe src="demo_iframe.htm" frameborder="0"></iframe>


25.插入指令碼 <script>

<script type="text/javascript">document.write("Hello World!")</script>


26.<head>所有頭部元素的容器
可包含<title> <base> <link> <meta> <script> <style>
<title>定義文檔標題
<base>為頁面上的所有連結規定預設的地址
<link>常用於串連樣式表
<style>為html文檔定義樣式資訊
<meta>用於規定頁面的描述、關鍵詞、文檔的作者、最後修改時間以及其他中繼資料。

 

一些小技巧:

設定背景圖片

<body background="/i/eg_background.jpg">

 

設定圖片對齊:

<p>映像 <img src ="/i/eg_cute.gif" align="middle"> 在文本中</p>

預設為bottom


將段落浮動至段落左邊或右邊:

<img src ="/i/eg_cute.gif" align ="left">

 

通過height和width屬性放大或縮小映像

<img src="/i/eg_mouse.jpg" width="100" height="100">

 

建立有可供點擊地區的映像地圖,其中每個地區是一個超連結

<imgsrc="/i/eg_planets.jpg"border="0" usemap="#planetmap"alt="Planets" /><map name="planetmap" id="planetmap"><areashape="circle"coords="180,139,14"href ="/example/html/venus.html"target ="_blank"alt="Venus" /><areashape="circle"coords="129,161,10"href ="/example/html/mercur.html"target ="_blank"alt="Mercury" /><areashape="rect"coords="0,0,110,260"href ="/example/html/sun.html"target ="_blank"alt="Sun" /></map>

 

處理空儲存格:
用&nbsp;代替裡面的內容
設定跨行或跨列的表格儲存格


橫跨兩列的儲存格:

<th colspan="2">電話</th>

 

橫跨兩行的儲存格

<th rowspan="2">電話</th>

 

設定儲存格邊距(儲存格內容與邊框之間的空白)

<table border="1" cellpadding="10">

 

設定儲存格間距(儲存格之間距離)

<table border="1" cellspacing="10">

 

在表格中添加背景顏色或背景映像

<table border="1" bgcolor="red"><table border="1" background="/i/eg_bg_07.gif">

 

在表格單元中排列內容

<th align="right">一月</th>


設定不同類型的有序列表
通過改變type屬性的值來改變排序的顯示方式
<ol type="A"> 以大寫字母類型排序
<ol type="a"> 以小寫字母類型排序
<ol type="I">以羅馬字母類型排序
<ol type="i">以小寫羅馬字母類型排序
預設是以數字排序

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.