【问题标题】:Can we write Legend tag twice inside a fieldset tag?我们可以在字段集标签内写两次 Legend 标签吗?
【发布时间】:2021-04-21 01:58:13
【问题描述】:

我们可以在<fieldset> 中写两次<legend> 标签吗?
我们可以在<fieldset> 中包含<p> 标签吗?

<fieldset>
    <legend>Feedback</legend>
    <p>Did you like it?</p>
    <input type="checkbox" name="level" value="low" />
    <label for="level">I didn't Like it.</label>
    <input type="checkbox" name="level" value="high" />
    <label for="level">Heck, Yes.</label>
    <legend>Subscribe for newsletter:</legend>        
    <input type="radio" name="newsletter" value="yes">
    <label for="newsletter">Yes</label>
    <input type="radio" name="newsletter" value="no">
    <label for="newsletter">No</label>
</fieldset>

【问题讨论】:

    标签: html forms fieldset


    【解决方案1】:

    从技术上讲,1 个图例。多个ps 都可以。请参阅技术摘要 here 并查看指向“流内容”的链接。

    【讨论】:

      【解决方案2】:

      根据 W3 规范:"The name of the group is given by the first legend element that is a child of the fieldset element, if any. The remainder of the descendants form the group." 没有迹象表明存在多个图例标签将是无效的 HTML,但我认为拥有多个图例标签并不是一个好主意。是的,可以在字段集中添加 p 标签。看看我提供的链接中的示例。

      【讨论】:

        猜你喜欢
        • 2017-05-15
        • 1970-01-01
        • 2011-02-19
        • 2015-09-01
        • 1970-01-01
        • 2019-09-30
        • 1970-01-01
        • 2020-03-21
        • 1970-01-01
        相关资源
        最近更新 更多