-
HTML块
<div>可对大块元素进行属性设置(块元素)
<span>可用作文本容器(内联元素,与CSS一起使用可用于为部分文本设置样式属性)
块级元素在浏览器显示时,通常会以新行来开始(和结束)。内联元素在显示时通常不会以新行开始。
<body> <p>我不在div里</p> <div style="color:#FF9966" > <p>我在div里</p> <p>我也在div里</p> </div> </body> </html>
-
HTML类(对HTML进行分类,为元素类定义CSS样式)
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <style> .cities{ background:#FF0066; color:#0033FF; margin:30px; } .green { color:#00FF33; } </style> <body> <div class="cities"> <h2 ><span class="green">CHINA</span></h2> BeiJIng </div> </body> </html>
-
HTML表单(收集用户输入)
<form>元素定义HTML表单
HTML表单元素:
<input>元素是最重要的表单元素
input的type属性:
text 常规文本输入
radio 定义单选按钮输入
submit 定义提交按钮
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <form> first:<br > <input type ="text" name"=first"> <br> second<br> <input type="text" name="second"> <br> <input type="radio" name="sex" value="male">male <br /> <input type="radio" name="sex" value="female">female <br /> <input type="submit" name="submit"> </form> </body> </html>
<select>元素定义下拉列表。
<option> 元素定义待选择的选项。
<textarea> 元素定义多行输入字段(文本域)。
<button> 元素定义可点击的按钮。
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <form> <select name="蔬菜"> <option value="茄子">茄子</option> <option value="青菜">青菜</option> </select> <input type="submit" /> <textarea name="input" cols="20" rows="20"> I want to eat an apple </textarea> <button type="button" onclick="alert('hi')">click me</button> </form> </body> </html>