Day14 HTML

概述

HTML是英文Hyper Text Mark-up Language(超文本标记语言)的缩写,他是一种制作万维网页面标准语言(标记)。相当于定义统一的一套规则,大家都来遵守他,这样就可以让浏览器根据标记语言的规则去解释它。
浏览器负责将标签翻译成用户“看得懂”的格式,呈现给用户!(例:djangomoan模版引擎)

Doctype 文档类型

Doctype告诉浏览器使用什么样的html或xhtml规范来解析html文档

有和无的区别:

  1. BackCompat:标准兼容模式未开启(或叫怪异模式[Quirks mode]、混杂模式)
  2. CSS1Compat:标准兼容模式已开启(或叫严格模式[Standards mode/Strict mode])

这个属性会被浏览器识别并使用,但是如果你的页面没有DOCTYPE的声明,那么compatMode默认就是BackCompat,这也就是恶魔的开始 -- 浏览器按照自己的方式解析渲染页面,那么,在不同的浏览器就会显示不同的样式。如果你的页面添加了那么,那么就等同于开启了标准模式,那么浏览器就得老老实实的按照W3C的标准解析渲染页面,这样一来,你的页面在所有的浏览器里显示的就都是一个样子了。
Doctype告诉浏览器使用什么样的html或xhtml规范来解析html文档, dtd文件则包含了标记、attributes 、properties、约束规则。

Meta(metadata information)

提供有关页面的元信息,例:页面编码、刷新、跳转、针对搜索引擎和更新频度的描述和关键词

  1. 页面编码(告诉浏览器是什么编码)
< meta http-equiv=“content-type” content=“text/html;charset=utf-8”>
<meta charset="UTF-8">
  1. 刷新和跳转
< meta http-equiv=“Refresh” Content=“30″>
< meta http-equiv=”Refresh“ Content=”5; Url=http://www.autohome.com.cn“ />
  1. 关键词
< meta name="keywords" content="星际2,星际老男孩,专访,F91,小色,JOY" >

描述
例如:cnblogs

X-UA-Compatible

微软的IE6是通过XP、Win2003等操作系统发布出来,作为占统治地位的桌面操作系统,也使得IE占据了通知地位,许多的网站开发的时候,就按照IE6的标准去开发,而IE6自身的标准也是微软公司内部定义的。到了IE7出来的时候,采用了微软公司内部标准以及部分W3C的标准,这个时候许多网站升级到IE7的时候,就比较痛苦,很多代码必须调整后,才能够正常的运行。而到了微软的IE8这个版本,基本上把微软内部自己定义的标准抛弃了,而全面的支持W3C的标准,由于基于对标准彻底的变化了,使得原先在早期IE8版本上能够访问的网站,在IE8中无法正常的访问,会出现一些排版错乱、文字重叠,显示不全等各种兼容性错误。

  1. 与任何早期浏览器版本相比,Internet Explorer 8 对行业标准提供了更加紧密的支持。 因此,针对旧版本的浏览器设计的站点可能不会按预期显示。 为了帮助减轻任何问题,Internet Explorer 8 引入了文档兼容性的概念,从而允许您指定站点所支持的 Internet Explorer 版本。 文档兼容性在 Internet Explorer 8 中添加了新的模式;这些模式将告诉浏览器如何解释和呈现网站。 如果您的站点在 Internet Explorer 8 中无法正确显示,则可以更新该站点以支持最新的 Web 标准(首选方式),也可以强制 Internet Explorer 8 按照在旧版本的浏览器中查看站点的方式来显示内容。 通过使用 meta 元素将 X-UA-Compatible 标头添加到网页中,可以实现这一点。

  2. 当 Internet Explorer 8 遇到未包含 X-UA-Compatible 标头的网页时,它将使用 指令来确定如何显示该网页。 如果该指令丢失或未指定基于标准的文档类型,则 Internet Explorer 8 将以 IE5 模式(Quirks 模式)显示该网页。更多

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

内联标签(行内标签)和块级标签

块级元素—h1,h2,h3,h4,h5,h6,hr,div,fieldset,form,dl,address,ol,p,table,ul,pre等。
内联元素—a,b,br,em,i,img,input,strong,textarea,span,label等。

他们两个的区别:

  1. 块级元素一般用来搭建网站架构、布局、承载内容
  2. 内联元素一般用来在网站内容中的某些细节或者部位,用以“强调、区分样式、上标、下标、锚点”等等。
  3. 它们可以互相转换。display:inline|block
  4. 块级元素的特点:每一个块级元素都识从一个新行开始显示,其后的元素需要另起一行。
  5. 内敛标签的特点:位置多少就占用多少,不会另起一行.

Title

网页头部信息

  1. css
  2. < link rel="stylesheet" type="text/css" href="css/common.css" >
  3. icon
  4. < link rel="shortcut icon" href="image/favicon.ico">

Style

在页面中写样式
例如:
< style type="text/css" >
.bb{
      background-color: red;
   }
< /style>

Script

  1. 引进文件
< script type="text/javascript" src="http://www.googletagservices.com/tag/js/gpt.js"> </script >
  1. 写js代码
< script type="text/javascript" > ... </script >

常用标签

标签一般分为两种:块级标签 和 行内标签

  • a、span、select 等
  • div、h1、p 等

各种符号

链接

p 和 br

p表示段落,默认段落之间是有间隔的!
br 是换行

a标签

< a href="http://www.autohome.com.cn">
1、target属性,_black表示在新的页面打开
2、锚

h 标签

<h1>Hello</h1>
<h2>Hello</h2>
<h3>Hello</h3>
<h4>Hello</h4>
<h5>Hello</h5>
<h6>Hello</h6>

checkbox

复选框
<br />sinning <input type="checkbox" name="hobby" value="1"/>
<br />painting <input type="checkbox" name="hobby" value="2"/>
<br />writing <input type="checkbox" name="hobby" value="3"/>
<br />dancing <input type="checkbox" name="hobby" value="4"/>

redio

<br />boy <input type="radio" name="sex" value="0"/>
<br />girl <input type="radio" name="sex" value="1"/>

password

<p>password: <input type="password" name="password"/></p>

button

<p>Button: <input type="button" value="button"/></p>

submit

<p>Submit: <input type="submit" value="submit"/></p>

reset

<p>Reset: <input type="reset" value="reset"/></p>

file

Upload:

提交文件时: enctype='multipart/form-data' method='POST'

textarea

<p>TextArea: <textarea name="info"></textarea></p>

select

<select name="multiaddress">
<optgroup label="Beijing">
<option value="1">HuiLongGuan</option>
<option value="2">ShangDi</option>
<option value="3">ShangHe</option>
</optgroup>
<optgroup label="GuangZhou">
<option value="4">AAA</option>
<option value="5">BBB</option>
<option value="6">CCC</option>
</optgroup>
</select>

label

<h2>label</h2>
姓名:<input id='name1' type='text' />
婚否:<input id='marriy1' type='checkbox' />
<br/>
<label for='name2'>姓名:<input id='name2' type='text' /></label>
<label for='marriy2'>婚否:<input id='marriy2' type='checkbox' /></label>

ul ol dl

ul

  • ul.li
  • ul.li
  • ul.li

ol

  1. ol.li
  2. ol.li
  3. ol.li

dl

  • 河北省
    邯郸
    石家庄

  • 山西省
    太原
    平遥

table

<table border="1">
<tr>
<th rowspan="2">第一列</th>
<th>第二列</th>
<th>第三列</th>
</tr>
<tr>
<td>第一列</td>
<td>第二列</td>
<!--<td>第三列</td>-->
</tr>
<tr>
<td colspan="2">第一列</td>
<td>第二列</td>
<!--<td>第三列</td>-->
</tr>
</table>

fieldset

<h2>fieldset</h2>
<fieldset>
<legend>登录</legend>
<p>用户名:</p>
<p>密码:</p>
</fieldset>

form

<h2>form 表单</h2>
<form method='POST' action='http://www.baidu.com'>
<input type='submit' value='submit'/>
</form>
<br/><br/><br/>
<form method='GET' action='http://www.baidu.com/s'>
<input type='text' name='wd'>
<input type='submit' value='submit'/>
</form>

CSS

css是英文Cascading Style Sheets的缩写,称为层叠样式表,用于对页面进行美化。
存在方式有三种:元素内联、页面嵌入和外部引入,比较三种方式的优缺点。

语法:style = 'key1:value1;key2:value2;'

在标签中使用 style='xx:xxx;'
在页面中嵌入 < style type="text/css"></style >
引入外部css文件
必要性:美工会对页面的色彩搭配和图片的美化负责,开发人员则必须知道是如何实现的。

标签选择器

div{ background-color:red; } 
<div > </div>

class选择器

.bd{ background-color:red; } 
<div class='bd'> </div>

id选择器

#idselect{ background-color:red; } 
<div id='idselect' > </div>

关联选择器


#idselect p{ background-color:red; } 

<div id='idselect' > <p> </p> </div> 

组合选择器

input,div,p{ background-color:red; } 

属性选择器

input[type='text']{ width:100px; height:200px; }

background

background-color		# 背景色

background-image	# 背景图片

background-repeat	# 背景图片效果(no-repeat; repeat-x; repeat-y)

background-position	# 背景图片位置

border

边框

border

border-top

border-bottom

border-left

border-right

margin

外边距

padding

内边距

display

display:none

original

display:block	# 使用block,块级标签变成内联标签

display:inline	# 使用inline,内联标签变成块级标签

cursor

  • css提供的cursor值

pointer || help || wait || move || crosshair

  • 伪造超链接

pointer

  • 自定义(一般不用)

mine

浮动 float

left

position

透明度

img{
  opacity:0.4;
  filter: alpha(opacity=40); /* 针对 IE8 以及更早的版本
}
posted @ 2016-08-13 11:56  摸个鱼儿  阅读(101)  评论(0编辑  收藏  举报