Html语言基础
接触html有一段时间了,对html做简单的总结。
1、HTML基础标签
<p>这是段落</p>
浏览器中效果:
这是段落
------------------------------------------------------------------------------
<p>
这个段落
在源代码中
包含许多行
但是浏览器
忽略了它们。
</p>
<p>
这个段落 在源代码 中 包含 许多行 但是 浏览器 忽略了 它们。
</p>
浏览器中效果:
这个段落 在源代码中 包含许多行 但是浏览器 忽略了它们。
这个段落 在源代码 中 包含 许多行 但是 浏览器 忽略了 它们。
-----------------------------------------------------------------------------------
<h1>春晓</h1>
<p>
春眠不觉晓,
处处闻啼鸟。
夜来风雨声,
花落知多少。
</p>
<p>
注意,浏览器忽略了源代码中的排版(省略了多余的空格和换行)。
</p>
浏览器中效果:
春晓
春眠不觉晓, 处处闻啼鸟。 夜来风雨声, 花落知多少。
注意,浏览器忽略了源代码中的排版(省略了多余的空格和换行)。
-----------------------------------------------------------------------------------------------
//拆行:
<p>
to break<br />lines<br />today is<br />fine day.
</p>
浏览器中效果:
to break
lines
today is
fine day.
-------------------------------------------------------------------------------------------------
//标题:
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<p>请仅仅把标题标签用于标题文本。不要仅仅为了产生粗体文本而使用它们。请使用其它标签或 CSS 代替。</p>
浏览器中效果:
This is heading 1
This is heading 2
请仅仅把标题标签用于标题文本。不要仅仅为了产生粗体文本而使用它们。请使用其它标签或 CSS 代替。
----------------------------------------------------------------------------------------------------------
//标题居中(可以居中、居右、居左):
<h2 align="center"> this is h2 heading</h2>
浏览器中效果:
this is h2 heading
----------------------------------------------------------------------------------------------------------------------------
//定义水平线
<p> hr 标签定义水平线:</p>
<hr />
<p> 这是段落</p>
<hr />
浏览器中效果:
hr 标签定义水平线:
这是段落
-----------------------------------------------------------------------------------------
//背景颜色:
<body bgcolor="yellow">
<h2>请看: 改变了颜色的背景。</h2>
</body>
浏览器中效果:
不好显示,说明:背景颜色变成黄色。
2、HTML文本格式化
//文本格式化
<b>This text is bold</b>
<br />
<strong>this is strong</strong>
<br />
<big>this text is big</big>
<br />
<em>this text is emphasized</em>
<br />
<i>this text is italic</i>
<br />
<small>this text is small</small>
<br />
this text contains <sub>subscript</sub> this text contains <sup>superscript</sup>
浏览器中效果:
This text is bold
this is strong
this text is big
this text is emphasized
this text is italic
this text is small
this text contains subscript this text contains superscript
----------------------------------------------------------------------------------------
//预格式文本
<pre>
这是
预格式文本。
它保留了 空格
和 换行。
</pre>
<p>
pre 标签很适合显示计算机代码:</p>
<pre>
for i = 1 to 10
print i
next i
</pre>
浏览器中效果:
这是 预格式文本。 它保留了 空格 和 换行。
pre 标签很适合显示计算机代码:
for i = 1 to 10 print i next i------------------------------------------------------------------------------------------//计算机输出标签:签很适合显示计算
<code>Computer code</code>
<br />
<kbd>keyboard input</kbd>
<br />
<tt>Teletype text</tt>
<br />
<samp>
Sample Text
</samp>
<br />
<var>
Computer variable</var>
<p>
<b>注释:</b>这些标签常用于显示计算机/编程代码。
</p>
浏览器中效果:
Computer code
keyboard input
Teletype text
Sample Text
Computer variable
注释:这些标签常用于显示计算机/编程代码。
-------------------------------------------------------------------------------------------
//缩写和首字母缩写
<abbr title="etccetera">
etc.</abbr>
<br />
<acronym title="world wide web">www</acronym>
<p>
在某些浏览器中,当您把鼠标移至缩略词语上时,title 可用于展示表达的完整版本。</p>
<p>
仅对于 IE 5 中的 acronym 元素有效。</p>
<p>
对于 Netscape 6.2 中的 abbr 和 acronym 元素都有效。</p>
浏览器中效果:
etc.
www
在某些浏览器中,当您把鼠标移至缩略词语上时,title 可用于展示表达的完整版本。
仅对于 IE 5 中的 acronym 元素有效。
对于 Netscape 6.2 中的 abbr 和 acronym 元素都有效。
------------------------------------------------------------------------------------------
//文字方向:
<p>
如果您的浏览器支持 bi-directional override (bdo),下一行会从右向左输出 (rtl);
</p>
<bdo>today is fine day</bdo>
<br />
<bdo dir="rtl">today is fine day</bdo>
浏览器中效果:
如果您的浏览器支持 bi-directional override (bdo),下一行会从右向左输出 (rtl);
today is fine day
today is fine day
-------------------------------------------------------------------------------------------
//块引用
长引用:
<blockquote>
差点等等等等等等等等等等等等等等等等,等等等等等等等等等等等等等等等等 等等饿饿饿饿饿饿饿饿饿饿饿
</blockquote>
<br />
短引用: <q>这是短引用 </q>
<p>
使用 blockquote 元素的话,浏览器会插入换行和外边距,而 q 元素不会有任何特殊的呈现。
</p>
浏览器中效果:
长引用:
差点等等等等等等等等等等等等等等等等,等等等等等等等等等等等等等等等等 等等饿饿饿饿饿饿饿饿饿饿饿
短引用: 这是短引用
使用 blockquote 元素的话,浏览器会插入换行和外边距,而 q 元素不会有任何特殊的呈现。
--------------------------------------------------------------------------------------------------------------
//删除子效果和插入字效果
<p>
今天好<del>明天</del> 后天 <ins>昨天</ins>前天</p>
<p>
大多数浏览器会改写为删除文本和下划线文本。</p>
<p>
一些老式的浏览器会把删除文本和下划线文本显示为普通文本。</p>
浏览器中效果:
今天好明天 后天 昨天前天
大多数浏览器会改写为删除文本和下划线文本。
一些老式的浏览器会把删除文本和下划线文本显示为普通文本。
3、HTML链接
//创建超级链接
<p>
<a href="./About.aspx">文本</a>执行另一个页面的链接。
</p>
<p>
<a href="http://www.microsoft.com/">本文本</a> 是一个指向万维网上的页面的链接。</p>
浏览器中效果:
文本执行另一个页面的链接。
本文本 是一个指向万维网上的页面的链接。
---------------------------------------------------------------------------------------------------
//将图像作为链接
<p>
使用图像来链接: <a href="http://www.w3school.com.cn/html/html_scripts.asp">
<img border="0" src="/image/11.jpg" width="100" height="100" />
</a>
</p>
浏览器中效果:
使用图像来链接:
---------------------------------------------------------------------------------------------------------
//在新的浏览器窗口打开链接
<a href="http://www.w3school.com.cn/" target="_blank">Visit w3shcool</a>
<p>
如果把链接的 target 属性设置为 "_blank",该链接会在新窗口中打开。</p>
浏览器中效果:
如果把链接的 target 属性设置为 "_blank",该链接会在新窗口中打开。
----------------------------------------------------------------------------------------------------
//链接到同一个页面的不同位置
<p>
<a href="#C4">查看 Chapter 4。</a>
</p>
<h2>
Chapter 1</h2>
<p>
This chapter explains ba bla bla</p>
<h2>
Chapter 2</h2>
<p>
This chapter explains ba bla bla</p>
<h2>
Chapter 3</h2>
<p>
This chapter explains ba bla bla</p>
<h2>
<a name="C4">Chapter 4</a></h2>
<p>
This chapter explains ba bla bla</p>
<h2>
Chapter 5</h2>
浏览器中效果:
Chapter 1
This chapter explains ba bla bla
Chapter 2
This chapter explains ba bla bla
Chapter 3
This chapter explains ba bla bla
Chapter 4
This chapter explains ba bla bla
Chapter 5
This chapter explains ba bla bla
------------------------------------------------------------------------------------------------
//跳出框架
<p>被锁在框架中了吗?</p>
<a href="Default.aspx" target ="_top">点击这里</a>
浏览器中效果:
被锁在框架中了吗?
HTML实例有很多,本次只是总结了一部分,余下的部分下次再做总结。
继续介绍Html的基础实例。
1、HTML表格
表格
<p>
每个表格由 table 标签开始。</p>
<p>
每个表格行由 tr 标签开始。</p>
<p>
每个表格数据由 td 标签开始。</p>
<h4>一列</h4>
<table border ="1">
<tr>
<td>100</td>
</tr>
</table>
<h4>一行三列:</h4>
<table border="2" >
<tr>
<td >100</td>
<td >200</td>
<td >300</td>
</tr>
</table>
<h4>两行三列:</h4>
<table >
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>100</td>
<td>300</td>
<td>500</td>
</tr>
</table>
浏览器中效果:
每个表格由 table 标签开始。
每个表格行由 tr 标签开始。
每个表格数据由 td 标签开始。
一列:
100 |
一行三列:
100 | 200 | 300 |
两行三列:
100 | 200 | 300 |
400 | 500 | 600 |
---------------------------------------------------------------------------------------------------------------------------------------
表格边框
<h4>带有普通的边框:</h4>
<table border="1">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>带有粗的边框:</h4>
<table border="8">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
浏览器中的效果:
带有普通的边框:
First | Row |
Second | Row |
带有粗的边框:
First | Row |
Second | Row |
注:此处并没有表现出边框的效果。
---------------------------------------------------------------------------------------------------------------------------
没有边框的表格
<h4>这个表格没有边框:</h4>
<table>
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
</table>
<h4>这个表格也没有边框:</h4>
<table border="0">
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
</table>
浏览器中的效果:
这个表格没有边框:
100 | 200 | 300 |
400 | 500 | 600 |
这个表格也没有边框:
100 | 200 | 300 |
400 | 500 | 600 |
--------------------------------------------------------------------------------------------------------------------------
表格中的表头
<h3>表头:</h3>
<table border ="3">
<tr>
<th>姓名</th>
<th>年龄</th>
<th>电话</th>
</tr>
<tr>
<td>bom</td>
<td>23</td>
<td>1234</td>
</tr>
</table>
<h3>垂直表头:</h3>
<table border ="3">
<tr>
<th>姓名</th>
<td>jim</td>
<td>bom</td>
</tr>
<tr>
<th>年龄</th>
<td>22</td>
<td>33</td>
</tr>
</table>
浏览器中的效果:
表头:
姓名 | 年龄 | 电话 |
---|---|---|
bom | 23 | 1234 |
垂直表头:
姓名 | jim | bom |
---|---|---|
年龄 | 22 | 33 |
---------------------------------------------------------------------------------------------------------------------------
空单元格
<table border="1">
<tr>
<td>Some text</td>
<td>Some text</td>
</tr>
<tr>
<td> </td>
<td>Some text</td>
</tr>
</table>
浏览器中效果:
Some text | Some text |
Some text |
-------------------------------------------------------------------------------------------------------------------------
带有标题的表格
<table border="6">
<caption>我的标题</caption>
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
</table>
浏览器中的效果:
我的标题
注:此次下方少一个表格。
--------------------------------------------------------------------------------------------------------------------------
跨行或跨列的表格单元格
<h4>横跨两列的单元格:</h4>
<table border="1">
<tr>
<th>姓名</th>
<th colspan="2">电话</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>555 77 854</td>
<td>555 77 855</td>
</tr>
</table>
<h4>横跨两行的单元格:</h4>
<table border="1">
<tr>
<th>姓名</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">电话</th>
<td>555 77 854</td>
</tr>
<tr>
<td>555 77 855</td>
</tr>
</table>
浏览器中的效果:
横跨两列的单元格:
姓名 | 电话 | |
---|---|---|
Bill Gates | 555 77 854 | 555 77 855 |
横跨两行的单元格:
姓名 | Bill Gates |
---|---|
电话 | 555 77 854 |
555 77 855 |
----------------------------------------------------------------------------------------------------------------------------
表格内的标签
<table border ="1">
<tr>
<td>
<p>这是个段落</p>
<p>这又是一个段落</p>
</td>
<td>
这个单元包含一个表格:
<table border ="2">
<tr>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
这个单元包含一个列表:
<ul>
<li>jim</li>
<li>jim2</li>
<li>jim3</li>
</ul>
</td>
<td>Hello world</td>
</tr>
</table>
浏览器中的效果:
这是个段落 这又是一个段落 |
这个单元包含一个表格:
|
||||
这个单元包含一个列表:
|
Hello world |
----------------------------------------------------------------------------------------------------------------------------
单元格边距
<h4>没有 cellpadding:</h4>
<table border="1">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>带有 cellpadding:</h4>
<table border="1"
cellpadding="10">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
浏览器中的效果:
没有 cellpadding:
First | Row |
Second | Row |
带有 cellpadding:
First | Row |
Second | Row |
注:此处没有显示出应有的效果。可以尝试下看看效果。
----------------------------------------------------------------------------------------------------------------------------
单元格间距
<h4>没有 cellspacing:</h4>
<table border="1">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>带有 cellspacing:</h4>
<table border="1"
cellspacing="10">
<tr>
<td>First</td>
<td>Row</td>
</tr>
<tr>
<td>Second</td>
<td>Row</td>
</tr>
</table>
浏览器中的效果:
没有 cellspacing:
First | Row |
Second | Row |
带有 cellspacing:
First | Row |
Second | Row |
注:此处没有显示出相应的效果。
------------------------------------------------------------------------------------------------------------------------------
向表格添加背景颜色或背景图片
<h4>两行三列:</h4>
<table border="1" cellspacing ="5" bgcolor="blue">
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>100</td>
<td>300</td>
<td>500</td>
</tr>
</table>
浏览器中的效果:
两行三列:
100 | 200 | 300 |
100 | 300 | 500 |
----------------------------------------------------------------------------------------------------------------------------
想表格单元添加背景颜色或背景图片,在表格单元中排列内容
<h4>一行三列:</h4>
<table border="2" width="200">
<tr>
<td bgcolor="red" align="right">100</td>
<td background="/image/11.jpg" align="center">200</td>
<td align="left">300</td>
</tr>
</table>
浏览器中的效果:
一行三列:
100 | 200 | 300 |
注:第二个表格单元的图片效果没有显示出来。
-------------------------------------------------------------------------------------------------------------------------------
框架属性
<p><b>注释:</b>frame 属性无法在 Internet Explorer 中正确地显示。</p>
<p>Table with frame="box":</p>
<table frame="box">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<p>Table with frame="above":</p>
<table frame="above">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
浏览器中的效果:
注释:frame 属性无法在 Internet Explorer 中正确地显示。
Table with frame="box":
Month | Savings |
---|---|
January | $100 |
Table with frame="above":
Month | Savings |
---|---|
January | $100 |
注:框架属性有frame=box,above,below,hsides, vsides。
Html语言基础的更多相关文章
- 《MSSQL2008技术内幕:T-SQL语言基础》读书笔记(下)
索引: 一.SQL Server的体系结构 二.查询 三.表表达式 四.集合运算 五.透视.逆透视及分组 六.数据修改 七.事务和并发 八.可编程对象 五.透视.逆透视及分组 5.1 透视 所谓透视( ...
- 《MSSQL2008技术内幕:T-SQL语言基础》读书笔记(上)
索引: 一.SQL Server的体系结构 二.查询 三.表表达式 四.集合运算 五.透视.逆透视及分组 六.数据修改 七.事务和并发 八.可编程对象 一.SQL Server体系结构 1.1 数据库 ...
- C#语言基础
第一部分 了解C# C#是微软公司在2000年7月发布的一种全新且简单.安全.面向对象的程序设计语言,是专门为.NET的应用而开发的.体现了当今最新的程序设计技术的功能和精华..NET框架为C#提供了 ...
- C语言基础回顾
第一章 C语言基础 1. C语言编译过程 预处理:宏替换.条件编译.头文件包含.特殊符号 编译.优化:翻译并优化成等价的中间代码表示或汇编代码 汇编:生成目标文件,及与源程序等效的目标的机器语言代码 ...
- 黑马程序员_ C语言基础(二)
------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- 概览 今天基础知识分为以下几点内容(注意:循环.条件语句在此不再赘述): 1.Hello W ...
- C#语言基础— 输入与输出
C#语言基础— 输入与输出 1.1函数的四要素:名称.输入.输出.加工 1.2主函数:输出语句.输入语句: Static viod Main(string[] stgs)//下划线部分可以自己指定 { ...
- 【GoLang】GO语言系列--002.GO语言基础
002.GO语言基础 1 参考资料 1.1 http://www.cnblogs.com/vimsk/archive/2012/11/03/2736179.html 1.2 https://githu ...
- R语言基础:数组&列表&向量&矩阵&因子&数据框
R语言基础:数组和列表 数组(array) 一维数据是向量,二维数据是矩阵,数组是向量和矩阵的直接推广,是由三维或三维以上的数据构成的. 数组函数是array(),语法是:array(dadta, d ...
- OC语言基础知识
OC语言基础知识 一.面向对象 OC语言是面向对象的,c语言是面向过程的,面向对象和面向过程只是解决问题的两种思考方式,面向过程关注的是解决问题涉及的步骤,面向对象关注的是设计能够实现解决问题所需功能 ...
- Java学习总结(二)----Java语言基础
1. Java语言基础 2.1 关键字 定义:被java语言赋予特殊含义的单词 特点:关键字中的字母都为小写 用于定义数据类型的关键字 class,interface,byte,short,i ...
随机推荐
- dtd语法之定义元素
1.语法:<!ELEMENT 元素名 使用规则> 使用规则: l (#PCDATA) :表示内容为普通文本数据 l EMPTY :表示元素内容必须为空 l ANY :元素出现任意次,一般用 ...
- WPF 中Frame + Page 的使用
1 在window 的设计的时候 ,中间需要进行页面切换的时候,顶一个Frame <Frame Name="MainPage" NavigationUIVisibility ...
- WPF的Page介绍及Page Window Frame 之间的链接使用示例,嵌套问题
本文源参考 http://www.cnblogs.com/ListenFly/archive/2013/02/24/2923474.html 谢谢源作者 WPF中的Page相比Window来说更加的精 ...
- Careercup | Chapter 7
7.4 Write methods to implement the multiply, subtract, and divide operations for integers. Use only ...
- 【iCore、iCore2 双核心板】EPCS 实验(SPI Flash)(基于Verilog语言)
_____________________________________ 深入交流QQ群: A: 204255896(1000人超级群,可加入) B: 165201798(500人超级群,满员) C ...
- Scrum会议6(Beta版本)
组名:天天向上 组长:王森 组员:张政.张金生.林莉.胡丽娜 代码地址:HTTPS:https://git.coding.net/jx8zjs/llk.git SSH:git@git.coding.n ...
- 移动端单页视图库,适用于制作移动Web touchbox
ouchBox 原文:https://github.com/maxzhang/touchbox 移动端单页视图库,适用于制作移动专题 DEMO http://jsbin.com/vatuma/late ...
- HDU 1069 基础动态规划+排序
题意 给出n种立方体石头 当且仅当一块石头的底部宽度长度都小于一块石头的时候才能放在上面 问最高能放多高?石头不限数目 然而同样一种石头采用同样的摆放方式 两快相同石头一定无法进行放置 所以 一块石头 ...
- Intel OIT demo
https://software.intel.com/en-us/blogs/2013/07/18/order-independent-transparency-approximation-with- ...
- PHP 魔术变量
PHP 魔术变量 PHP 向它运行的任何脚本提供了大量的预定义常量. 不过很多常量都是由不同的扩展库定义的,只有在加载了这些扩展库时才会出现,或者动态加载后,或者在编译时已经包括进去了. 有八个魔术常 ...