语义正确的 XHTML 标记

发布于 2024-09-06 06:25:48 字数 598 浏览 3 评论 0原文

只是尝试掌握使用语义上正确的 XHTML 标记的窍门。

只需编写一个小型导航项的代码即可。每个按钮都有一个有效的标题和描述。因此,我认为定义列表会很棒,所以我写了以下内容

<dl>
    <dt>Import images</dt>
    <dd>Read in new image names to database</dd>

    <dt>Exhibition Management</dt>
    <dd>Create / Delete an exhibition </dd>

    <dt>Image Management</dt>
    <dd>Edit name, medium and exhibition data  </dd>
</dl>

但是...我希望上面有 3 个按钮,每个按钮包含 dt 和 dd 文本。我怎样才能用正确的代码做到这一点?通常我会将每个按钮设为一个 div 并将其用于视觉按钮行为(onHover 和当前页面选择内容)。

有什么建议请

谢谢

Just trying to get the hang of using the semantically correct XHTML markup.

Just writing the code for a small navigation item. Where each button has effectivly a title and a descrption. I thought a definition list would therefore be great so i wrote the following

<dl>
    <dt>Import images</dt>
    <dd>Read in new image names to database</dd>

    <dt>Exhibition Management</dt>
    <dd>Create / Delete an exhibition </dd>

    <dt>Image Management</dt>
    <dd>Edit name, medium and exhibition data  </dd>
</dl>

But...I want the above to be 3 buttons, each button containing the dt and dd text. How can i do this with the correct code? Normally i would make each button a div and use that for the visual button behaviour (onHover and current page selection stuff).

Any advice please

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风吹雨成花 2024-09-13 06:25:48
<ul>
    <li><a href="#" title="Read in new image names to database">Import images</a></li>
    <li><a href="#" title="Create / Delete an exhibition">Exhibition Management</a></li>
    <li><a href="#" title="Edit name, medium and exhibition data">Image Management</a></li>
</ul>

这就足够了。
使用

进行导航并不是很聪明。或者在

  • 内使用 和描述。
    会让你很头痛,因为它们不在
    内部并且不关心它的位置和样式
  • <ul>
        <li><a href="#" title="Read in new image names to database">Import images</a></li>
        <li><a href="#" title="Create / Delete an exhibition">Exhibition Management</a></li>
        <li><a href="#" title="Edit name, medium and exhibition data">Image Management</a></li>
    </ul>
    

    thats good enough.
    using <dl> for navigation is not very clever. or use a <span> inside the <li> with the description. <dd> will give you much headache since they aren't inside the <dt> and don't care about its position and styling

    ㄖ落Θ余辉 2024-09-13 06:25:48

    我对您使用的术语“按钮”感到有点困惑。如果您指的是链接,那么您可以这样做:

    <a href="dest.html" title="Read in new image names to database">Import images</a>
    

    但是,如果您指的是输入标记,那么实现此目的的一种方法是使用 input type=image,然后提供 alt 描述。

    例如:

    <input type="image" src="image.jpg" value="Import images" alt="Read in new image names to database"/>
    

    I am slightly confused by the use of your term "button". If you mean a link, then you could do:

    <a href="dest.html" title="Read in new image names to database">Import images</a>
    

    If, however, you mean the input tag, then one way to do this would be to use input type=image and then provide an alt description.

    For instance:

    <input type="image" src="image.jpg" value="Import images" alt="Read in new image names to database"/>
    
    临走之时 2024-09-13 06:25:48

    您可以使用 元素代替

    元素:

    <ul>
        <li>
            <a href="#">
                <label for="import-images">Import images</label>
                <span id="import-images">Read in new image names to database</span>
            </a>
        </li>
        <li>
            <a href="#">
                <label for="exhibition-management">Exhibition Management</label>
                <span id="exhibition-management">Create / Delete an exhibition</span>
            </a>
        </li>
        <li>
            <a href="#">
                <label for="image-management">Image Management</label>
                <span id="image-management">Edit name, medium and exhibition data</span>
            </a>
        </li>
    </ul>
    

    ... for 属性label> 元素只需与文档中另一个元素的 id 匹配即可有效。

    You could use <label> elements instead of <dt> elements:

    <ul>
        <li>
            <a href="#">
                <label for="import-images">Import images</label>
                <span id="import-images">Read in new image names to database</span>
            </a>
        </li>
        <li>
            <a href="#">
                <label for="exhibition-management">Exhibition Management</label>
                <span id="exhibition-management">Create / Delete an exhibition</span>
            </a>
        </li>
        <li>
            <a href="#">
                <label for="image-management">Image Management</label>
                <span id="image-management">Edit name, medium and exhibition data</span>
            </a>
        </li>
    </ul>
    

    ... the for attribute of the <label> element need only match the id of another element in the document to be valid.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文