html常用标签
·表格标签:
<tr>:定义表格的行。(table row)
<td>:定义表格中的标准单元格。(table standard cell)
<th>:定义表格中的表头单元格。
表格中有两类单元格:表头单元(包含头部信息)、标准单元(包含数据)
- <table border = "1" align = "center">
- <tr>
- <th>ID</th>
- <th>Name</th>
- </tr>
- <tr>
- <td>001</td>
- <td>张三</td>
- </tr>
- </table>
·表单标签
<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>换行
空格
css层叠样式表
定义了html元素怎么去显示,一般存储在样式表中
分类及优先级排序:行内样式表、内嵌样式表、外部样式表、浏览器默认样式表
语法:
selector{property:value} (selector为要设定样式的html标签)
注意:如果值为多个单词,应该用双引号
如果有多个属性,用分号分隔开
示例:
·外部样式表
css文件:
- p{text-align:center;color:red}
html文件:
- <link rel="stylesheet" type="text/css" href="css.css">
- <p>xx</p>
·行内样式表的一种用法
- h1,h2,h3,h4,h5,h6{color:green}
·类选择器
如果是同一个标签不同样式的情况怎么办
css:
- p.right{text-align:right}
- p.center{text-align:center}
html:
- <p class="right"/>
- <p class="center"/>
·通用属性
- .center{text-align:center}
大家都可以通过class="center"引用
·id选择器
功能类似于类选择器
- p#green{color:green}
·各类样式表的使用方法
外部样式表
- html:
- <head><link rel="stylesheet" type="text/css"
- href="mystyle.css"/>
- </head>
- css:
- hr{color:green}
内嵌样式表
- html:
- <style type="text/css">
- center{text-align:center;color:red}
- </style>
行内样式表(不推荐使用)
- <p stype="color:red;margin-left:20px"></p>
多重样式表
补充一点:如果一个元素被多个样式表定义,那么我们选哪个呢?答:选定义最具体的那个。
转载于:https://blog.51cto.com/4798354/955521