HTML基础(二)

  • 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>

 

 

转载于:https://www.cnblogs.com/clean/p/7516177.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值