有for属性的html元素:1、label元素;for与label元素一起使用时,for属性指定标签绑定到哪个表单元素。2、output元素;for与output元素一起使用时,for属性指定计算结果与计算中使用的元素之间的关系。
本教程操作环境:windows7系统、HTML5版、Dell G3电脑。
for属性适用的html元素
元素名 说明 <label> for与<label>元素一起使用时,for属性指定标签绑定到哪个表单元素。 <output> for与<output>元素一起使用时,for属性指定计算结果与计算中使用的元素之间的关系。<label>标签for属性
for属性指定标签绑定到哪个表单元素。
语法
<label for="element_id">element_id:label 要绑定的元素的 id。
实例
<form action="/jc_script/action.php"> <label for="php">PHP</label> <input type="radio" name="lang" id="php" value="php"><br> <label for="java">Java</label> <input type="radio" name="lang" id="java" value="java"><br> <label for="python">Python</label> <input type="radio" name="lang" id="python" value="python"><br><br> <input type="submit" value="提交"> </form><output>标签for属性
for属性指定计算结果与计算中使用的元素之间的关系。
语法
<output for="element_id">实例
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0 <input type="range" id="a" value="50">100 +<input type="number" id="b" value="50"> =<output name="x" for="a b"></output> </form>推荐教程:《html视频教程》
以上就是哪些html元素有for属性的详细内容!
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did66782
哪些html元素有for属性
阅读:48次