对于像“返回顶部”这样的短文本应该使用什么标签? ,“阅读更多” ETC?

发布于 2024-08-17 05:45:17 字数 463 浏览 7 评论 0原文

像这样的短文本应该使用什么标签。

返回顶部

阅读更多

合适,或者应该使用其他内容。因为这些不是段落。

哪个更语义化

<p><a href="#mainWrapper">Back to top</a></p>

or

<a href="#mainWrapper">Back to top</a>

or

<div><a href="#mainWrapper">Back to top</a></div>

What tag should be used for short text like.

Back to top

Read more

is <p> appropirate or something else should be use. because these are not paragraph.

Which is more semantic

<p><a href="#mainWrapper">Back to top</a></p>

or

<a href="#mainWrapper">Back to top</a>

or

<div><a href="#mainWrapper">Back to top</a></div>

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

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

发布评论

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

评论(4

晚雾 2024-08-24 05:45:17

In general you should use the anchor <a> tag.

Nesting an <a> inside a <p> is perfectly valid, but in general the <p> should be reserved for paragraphs of text. Since yours is just a link, the <a> tag alone will probably be the most recommended.

If you want your link to appear as a block element, simply style it with display: block;. The fact that the <a> tag is normally displayed inline is only because it is its default style.

悲歌长辞 2024-08-24 05:45:17

锚标记

<a href="#">Back to top</a>

<a href="#">Read more</a>

您可以在块元素内嵌入锚标记。所以像这样的事情

<p><a href="#">Back to top</a></p>

Anchor tag

<a href="#">Back to top</a>

<a href="#">Read more</a>

You can embed an anchor tag inside a block element. So something like this

<p><a href="#">Back to top</a></p>
不知在何时 2024-08-24 05:45:17

内联元素必须包含在块级元素内,因此这是基本方法:

<p><a href="#">Back to top</a></p>

通常虽然 元素已经位于

标记内,所以

并不是绝对必要的,但它在语义上更正确 - 即使其中只有几个单词,它仍然是一段文本。

Inline elements must be enclosed inside block level elements, so this is the basic approach:

<p><a href="#">Back to top</a></p>

Usually though the <a> element is already inside a <div> tag so the <p> isn't absolutely necessary but it is more semantically correct – it's still a paragraph of text even if there's only a few words in it.

眼波传意 2024-08-24 05:45:17

没有明显的语义标签。

* 如果您需要一个仅用于构建或悬挂 CSS 样式的标签,请使用

There's no obvious semantic tag for such.

  • Perhaps you don't really need a tag there at all! Please check for this case.

  • If your "short texts" are links, then you obviously need <a href=. If you need a CSS style for the text, you can put it into the a tag too.

* If you need a tag for structuring only or to hang CSS styles from, then use <span>.

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