HTML input属性详谈

value属性

value属性指定输入字段的初始值:

<form>
         名字:<br>
         <input type="text" name="yourname" value="Jim"><br>
         姓氏:<br>
         <input type="text" name="homename" value="Green">
 </form>

readonly属性

readonly属性指定输入字段是只读的(不能更改):

<form action="/jc_script/urlencode.php" target="_blank">
         名字:<br>
         <input type="text" name="yourname" value="Jim"><br>
         姓氏:<br>
         <input type="text" name="homename" value="Green" readonly>
         <input type="submit"  value="提交">
</form>

disabled属性

disabled属性指定禁用输入字段。禁用的输入字段不可用且不可单击,并且在提交表单时不会发送其值:

<form action="/jc_script/urlencode.php" target="_blank">
         名字:<br>
         <input type="text" name="yourname" value="Jim"><br>
         姓氏:<br>
         <input type="text" name="homename" value="Green" disabled>
         <input type="submit"  value="提交">
</form>

size属性

size属性指定输入字段的大小(以字符为单位):

<form action="/jc_script/urlencode.php" target="_blank">
         名字:<br>
         <input type="text" name="yourname" value="Jim" size="40"><br>
         姓氏:<br>
         <input type="text" name="homename" value="Green">
         <input type="submit"  value="提交">
</form>

  

HTML5添加的属性

下表列出了HTML5添加的一些新属性:

属性名称 所属元素
autocomplete <form>,<input>
autofocus <input>
form <input>
formaction <input>
formenctype <input>
formmethod <input>
formnovalidate <input>
formtarget <input>
height <input>
width <input>
list <input>
min <input>
max <input>
multiple <input>
pattern (regexp) <input>
placeholder <input>
required <input>
step <input>
novalidate <form>

更多的HTML5 input 属性介绍

猜你喜欢

转载自www.cnblogs.com/jc2182/p/11690003.html