html - 什么样的文本可以包含在 HTML 代码标签中?
问题描述
我想知道哪种文本属于 HTML<code>
元素,哪些不属于?
例如,我知道这是 HTML<code>
标签的一个很好的用法:
Use the <code>str()</code> function to convert the object into a string.
但我不确定这些是否是<code>
标签的好用法:
1. The list of users can be found at <code>/etc/passwd</code>.
2. We need to wait for <code>200 OK</code> response before the next step.
3. Enter the <code>ls</code> command to obtain a directory listing.
4. Compile the source code in <code>foo.c</code> to <code>foo.o</code>.
是否有标准文档或 W3C 指南文档或类似的权威参考来精确定义哪些元素可能属于 HTML<code>
元素,哪些可能不属于?
解决方案
code
元素的定义(来自 HTML 5.2)是:
该
code
元素代表一段计算机代码。这可以是 XML 元素名称、文件名、计算机程序或计算机可以识别的任何其他字符串。
这决定了是否允许(即语义)使用该元素。但是您还应该检查是否有更具体的元素可用。
查看您的示例
Use the <code>str()</code> function to convert the object into a string.
这可以。
The list of users can be found at <code>/etc/passwd</code>.
这可以。
We need to wait for <code>200 OK</code> response before the next step.
您可以考虑改用该samp
元素,它表示“来自另一个程序或计算系统的样本或引用输出”。
Enter the <code>ls</code> command to obtain a directory listing.
您可以考虑改用该kbd
元素,它表示“用户输入(通常是键盘输入,[...])”。
Compile the source code in <code>foo.c</code> to <code>foo.o</code>.
这可以。
推荐阅读
- micronaut - 如何解决 micronaut 应用程序中的错误“没有 [io.micronaut.data.operations.PrimaryRepositoryOperations] 类型的 bean”?
- arrays - 如何遍历两个数组并在 Ruby 中创建地图
- java - 以对象或字符串作为参数覆盖
- python - Dockerized 烧瓶应用程序在本地构建和运行,但在 Azure 上部署时无法运行
- mysql - 如何将容器 IP 地址传递给另一个容器?
- node.js - 应用程序不会在 MongoDB 本地数据库上存储任何内容
- ios - 如何向 UITableViewCells Swift 添加多个按钮
- javascript - 如何在 AngularJS 中向 app.module() 动态添加控制器?
- swift - 快速惰性序列 - 为什么在引入定义时编译器会抱怨
- wordpress - Woocommerce - 如果客户选择“运送到其他地址?”,请通知管理员