版权声明:分享才能获得最大的价值 https://blog.csdn.net/qq_32252957/article/details/83995992
布尔属性:
XHTML 规范要求为布尔型属性赋值,到了HTML5,一切化繁为简。HTML5 规范规定:元素的布尔型属性如果有值,就是 true,如果没有值,就是 false。因此,在声明布尔型属性时,不用赋值。
我们可以看到<input>标签当时单选框的时候(radio),可以直接用checked表示预先初始选中的按钮。当然也可以checked="everything you can put into".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>The Starbuzz Bean Machine</title>
</head>
<body>
<h1>The Starbuzz Bean Machine</h1>
<h2>Fill out the form below and click submit to order</h2>
<form action="http://starbuzzcoffee.com/processorder.php" method="POST">
<p>
Choose your beans:
<select name="beans">
<!--value定义送往服务器的选项值
浏览器将表单元素的名和值打包时,它会使用<select>元素的名和所选选项的值
. 如果选择Bolivia选项,则浏览器会向服务器发送beans="Bolivia"-->
<option value="House Blend">House Blend</option>
<option value="Boliva">Shade Grown Boliva Supremo</option>
<option value="Guatemala">Organic Guatemala</option>
<option value="Kenya">Kenya</option>
</select>
</p>
<p>
Type: <br>
<!-- name一样,同组的所有单选框都有相同的名字, value是将要发送到服务器脚本
的值。只会提交表单时发送选中的那个单选按钮的值-->
<input type="radio" name="beantype" value="whole"> Whole bean<br>
<!--checked属性规定在页面加载时应该被预先选定的input元素-->
<input type="radio" name="beantype" value="ground" checked> Ground
<!--
<input type="radio" name="beantype" value="ground" checked="checked">Ground
-->
</p>
<p>Ship tp: <br>
Name: <input type="text" name="name"> <br>
Address: <input type="text" name="address"> <br>
City: <input type="text" name="city"> <br>
State: <input type="text" name="state"> <br>
Zip: <input type="text" name="zip"> <br>
Phone: <input type="tel" name="phone"> <br>
</p>
<p>
<!--value属性为这个输入域提供默认文本-->
<input type="submit" value="Order Now">
</p>
</form>
</body>
</html>