大网数据广告活动
Web 标准与前端开发

<samp>

· 52CE 我爱测

\<samp> 元素用于标识计算机程序输出,通常使用浏览器缺省的 monotype 字体(例如 Lucida Console)。

<samp> 元素用于标识计算机程序输出,通常使用浏览器缺省的 monotype 字体(例如 Lucida Console)。

<table class="properties"> <tbody> <tr> <th scope="row"><a href="/zh-CN/docs/Web/HTML/Guides/Content_categories">内容分类</a></th> <td><a href="/en/HTML/Content_categories#Flow_content">Flow content</a>, <a href="/en/HTML/Content_categories#Phrasing_content">phrasing content</a>, palpable content.</td> </tr> <tr> <th scope="row">允许内容</th> <td><a href="/en/HTML/Content_categories#Phrasing_content">Phrasing content</a>.</td> </tr> <tr> <th scope="row">标签省略</th> <td>不允许,开始标签和结束标签都不能省略。</td> </tr> <tr> <th scope="row">允许的父级元素</th> <td>Any element that accepts <a href="/zh-CN/docs/Web/HTML/Guides/Content_categories#Phrasing_content">phrasing content</a>.</td> </tr> <tr> <th scope="row">DOM 接口</th> <td>HTMLElement</td> </tr> </tbody> </table>

属性

该元素只包含 全局属性。

DOM 接口

该元素实现了 HTMLElement 接口。

[!NOTE] 基于 Gecko 1.9.2 及以上,Firefox 还为该元素实现了HTMLSpanElement 接口。

示例

<p>Regular text. <samp>This is sample text.</samp> Regular text.</p>

结果

Regular text. This is sample text. Regular text.

规范

注意

可以使用 CSS 选择器 samp 定义规则来覆盖浏览器的缺省字体。不过,用户设置的偏好可能会优先于指定的 CSS 使用。

参见

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。