标记对话(或采访)的最语义方式?

发布于 2024-12-25 17:42:24 字数 378 浏览 3 评论 0原文

我试图找出最语义化的方式来标记这样的东西。

John: blah blah 
Paul: blah blah 
George: blah blah 
Ringo: blah blah 

或者

John:   blah blah 
Paul:   blah blah 
George: blah blah 
Ringo:  blah blah 

理想情况下,CSS 可以灵活地执行或将其分成一个段落,其中名称可见或不可见。我考虑过使用 before: 选择器来添加名称,但我也希望它们是可链接的。例如,如果林戈有推特个人资料,我会链接到他的个人资料。它还应该在屏幕阅读器中正确阅读。

I'm trying to figure out the most semantic way to markup something like this.

John: blah blah 
Paul: blah blah 
George: blah blah 
Ringo: blah blah 

or

John:   blah blah 
Paul:   blah blah 
George: blah blah 
Ringo:  blah blah 

Ideally there'd be the CSS flexibility to do either or to break it into a paragraph with or without the names visible. I considered using the before: selector to add the names, but I also want them to be linkable. For example, I'd link to Ringo's twitter profile if he had one. It also should read properly in screenreaders.

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

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

发布评论

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

评论(2

梦言归人 2025-01-01 17:42:24

HTML5 规范对此进行了讨论,其要点是:

鼓励作者使用 p 元素和标点符号来标记对话。鼓励出于样式目的需要标记演讲者的作者使用 spanb。文本包含在 i 元素中的段落可用于标记舞台方向。

因此,最终,类似这样的事情:

<p><span>John:</span> blah blah</p>

<p><span>Paul:</span> blah blah</p>

<p><span>George:</span> blah blah</p>

<p><span>Ringo:</span> blah blah</p>

这将使您能够按照您描述的方式进行样式设置。当然,如果需要,您还可以添加 class 属性。您本能地不使用 :before 选择器将名称放入 CSS 中是一个很好的选择 - 此信息绝对应该位于标记中。

The HTML5 spec discusses this, the gist of which is:

Authors are encouraged to mark up conversations using p elements and punctuation. Authors who need to mark the speaker for styling purposes are encouraged to use span or b. Paragraphs with their text wrapped in the i element can be used for marking up stage directions.

So, ultimately, something like this:

<p><span>John:</span> blah blah</p>

<p><span>Paul:</span> blah blah</p>

<p><span>George:</span> blah blah</p>

<p><span>Ringo:</span> blah blah</p>

This would enable styling in the way you describe. You could, of course, also add class attributes if necessary. Your instinct not to put the names in CSS with the :before selector is a good one--this information should definitely be in the markup.

栀梦 2025-01-01 17:42:24

嗯。

提示 - 使用 xml 进行标记。应该会让以后更容易使用

类似

类的东西

hm.

Tip - use xml to mark it up. Should make it easier to work with later

something like <voice speaker="John"></voice>

maybe

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