html常用标签

·表格标签:

<tr>:定义表格的行。(table row)

<td>定义表格中的标准单元格。(table standard cell)

<th>定义表格中的表头单元格

   表格中有两类单元格:表头单元(包含头部信息)、标准单元(包含数据)

 
  
  1. <table border = "1" align = "center"> 
  2.     <tr> 
  3.         <th>ID</th> 
  4.         <th>Name</th> 
  5.     </tr> 
  6.     <tr> 
  7.         <td>001</td> 
  8.         <td>张三</td> 
  9.     </tr> 
  10. </table> 
  11.        

·表单标签

<form>

<input type="text"/> 普通文本框

<input type="password"/>密码输入框

<input type="checkbox"/>复选框

<input type="radio" name="单选"/> 单选按钮

<select><option>下拉</option><select> 下拉表单

<textarea>文本域</textarea> 文本域

</form>

·其他常用标签

<input type="file"/>文件上传

<input type="submit" value="submit"/>提交按钮

<input type="reset" value="reset"/>重置按钮

<input type="button" value="普通按钮"/>普通按钮

<img src="图片地址">显示图片

<br>换行

&nbsp;空格

 

css层叠样式表

定义了html元素怎么去显示,一般存储在样式表中

分类及优先级排序:行内样式表、内嵌样式表、外部样式表、浏览器默认样式表

语法:

selector{property:value} (selector为要设定样式的html标签)

注意:如果值为多个单词,应该用双引号

      如果有多个属性,用分号分隔开

示例:

·外部样式表

css文件:

 
  
  1. p{text-align:center;color:red} 

html文件:

 
  
  1. <link rel="stylesheet" type="text/css" href="css.css"> 
  2. <p>xx</p> 

·行内样式表的一种用法

 
  
  1. h1,h2,h3,h4,h5,h6{color:green} 

·类选择器

如果是同一个标签不同样式的情况怎么办

css:

 
  
  1. p.right{text-align:right} 
  2. p.center{text-align:center} 

html:

 
  
  1. <p class="right"/> 
  2. <p class="center"/> 

·通用属性

 
  
  1. .center{text-align:center}  

大家都可以通过class="center"引用

·id选择器

功能类似于类选择器

 
  
  1. p#green{color:green} 

·各类样式表的使用方法

外部样式表

 
  
  1. html: 
  2. <head><link rel="stylesheet" type="text/css" 
  3.     href="mystyle.css"/> 
  4. </head> 
  5. css: 
  6. hr{color:green} 

内嵌样式表

 
  
  1. html: 
  2. <style type="text/css"> 
  3. center{text-align:center;color:red} 
  4. </style> 

行内样式表(不推荐使用)

 
  
  1. <p stype="color:red;margin-left:20px"></p> 

多重样式表


补充一点:如果一个元素被多个样式表定义,那么我们选哪个呢?答:选定义最具体的那个。