Path // www.yourhtmlsource.comReference → <samp>

<samp>


The <samp> element represents sample or quoted output from a computer program, script, or system. This is typically rendered in the browser's default monospace font, making it visually distinct from regular text and clearly identifiable as computer-generated content.

Clock This page was last updated on 2025-11-17



Syntax

<samp>sample output</samp>

The element requires both opening and closing tags. The content represents the output that a computer program would produce.

Attributes

  • Global attributes - The <samp> element supports all global attributes such as id, class, style, lang, and dir.

The <samp> element has no element-specific attributes.

Examples

Simple Program Output

<p>The program will output: <samp>Hello, World!</samp></p>

Error Message

<p>If the file is not found, you will see: <samp>Error: File not found</samp></p>

Terminal Output with User Input

<p>The terminal shows: <samp>$ <kbd>ls -la</kbd>
total 48
drwxr-xr-x 12 user staff 384 Nov 17 10:30 .</samp></p>

System Status Message

<p>When installation completes, you'll see: <samp>Installation successful. 47 packages installed.</samp></p>

When to Use

Use the <samp> element when:

  • Showing expected output from running code or commands
  • Displaying error messages or system responses
  • Documenting terminal or console output
  • Quoting text generated by a computer system
  • Writing tutorials that show what users should expect to see

The <samp> element is often combined with:

  • <kbd> to show input within output contexts
  • <pre> for multi-line output blocks
  • <code> when the output is itself code
  • <kbd> - For user keyboard input
  • <code> - For code fragments
  • <var> - For variables in programming or mathematics
  • <pre> - For preformatted text blocks
  • <output> - For the result of a calculation or user action