--- title: slug: Web/HTML/Element/samp translation_of: Web/HTML/Element/samp ---

概述

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

内容分类 Flow contentphrasing content, palpable content.
允许内容 Phrasing content.
遗漏标签 {{no_tag_omission}}
允许的父级元素 Any element that accepts phrasing content.
DOM 接口 {{domxref("HTMLElement")}}

属性

该元素只包含 全局属性

DOM 接口

该元素实现了 HTMLElement 接口。

Implementation 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.

规范

规范 状态 备注
{{SpecName('HTML WHATWG', 'text-level-semantics.html#the-samp-element', '<samp>')}} {{Spec2('HTML WHATWG')}}  
{{SpecName('HTML5 W3C', 'text-level-semantics.html#the-samp-element', '<samp>')}} {{Spec2('HTML5 W3C')}}  
{{SpecName('HTML4.01', 'struct/text.html#h-9.2.1', '<samp>')}} {{Spec2('HTML4.01')}}  

注意

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

另请参阅

{{ HTMLRef }}