👀 Live Preview
Command output shown inline:
In this example, the output of the command is Hello, World!.

The <samp> tag marks sample output from programs and systems. This guide covers syntax, comparisons with code and kbd, styling, use cases, and best practices for beginners.
Program results.
Output not source.
Not key input.
Docs and blogs.
class and style.
Meaningful markup.
<samp> Tag?The <samp> tag is an HTML element designed to represent sample (or output) content. It is particularly useful when showcasing examples of computer code output, terminal text, or other types of sample data.
Use samp for what a program prints or returns. Use code for the source code itself.
Common in coding tutorials, API documentation, and tech blogs where you show command-line results or mock system responses inline.
Enclose the sample content within opening <samp> and closing </samp> tags:
<samp>Your Sample Output Here</samp>samp inline inside paragraphs and list items.pre for multi-line block output with preserved whitespace.class and style for presentation.| Topic | Code Snippet | Notes |
|---|---|---|
| Inline output | <samp>text</samp> | Sample result |
| Source code | Use code | Not samp |
| Keyboard keys | Use kbd | Not samp |
| Block output | Use pre | Multi-line |
| Styling | class, style | Global attrs |
| Browser support | Universal | All browsers |
<samp> vs <code> vs <kbd>| Element | Represents | Example |
|---|---|---|
<samp> | Program output | Hello, World! |
<code> | Source code | console.log() |
<kbd> | Keyboard input | Enter |
The <samp> tag has no tag-specific attributes. Use global attributes like class and style to customize the appearance of sample output.
<samp class="highlight" style="color: #0066cc;">
Your Styled Sample Output Here
</samp>class CSSApply a class for reusable sample output styling.
class="highlight"style InlineInline color, font, or background overrides.
style="color: #0066cc"title TooltipExtra context about the sample output.
title="Terminal output"Display program output and sample data with samp in tutorials and documentation.
Command output shown inline:
In this example, the output of the command is Hello, World!.
The <samp> tag represents computer code output and sample data within the context of a document.
The primary purpose of samp is to represent the output of computer code or commands.
In this example, the output of the command is <samp>Hello, World!</samp>.Use samp when presenting sample data, such as mock user input or system responses.
<samp>User Input: John Doe</samp>samp element carries semantic meaning beyond font styling.pre, not inline samp.Place sample program results inside samp tags.
Default styles display samp in a monospace font.
Optional class and style improve visual distinction.
Readers see program results distinguished from code and keys.
The <samp> tag is supported in all major browsers, including Internet Explorer.
All browsers render <samp> with default monospace styling.
Bottom line: Use <samp> confidently for sample output in any browser.
Mastering the <samp> tag empowers web developers to effectively showcase sample output and data within HTML documents. By following best practices and considering browser compatibility, you can enhance the clarity and visual appeal of your content.
samp for program output and sample datacode when showing input and outputsamp for source code snippetssamp for keyboard key namessamp<samp>Bookmark these before you mark sample output.
Program results.
PurposeUse code tag.
DistinctionKeys use kbd.
DistinctionDocs and blogs.
Contextclass / style.
CSSAll browsers.
Compatibilitysamp is program output. code is source code.class and style apply.pre for multi-line block output. Use samp for inline sample text.Practice <samp> for program output and sample data in the Try It editor.
6 people found this page helpful