HTML <samp> Tag Tutorial - Usage, Syntax,
Attributes and Example

calender-iconPublished: 11 May 2025

clock-icon5-min read





INTRODUCTION

The <samp> element is used to represent sample output from a program, system message, or command-line response. The HTML samp element is an inline element.

Display: By default, the text is shown by in the default monospace font of browser.


Syntax:
<samp> - TEXT - </samp>

You can use the <kbd> element along with <samp> element, to showcase an example that includes user-entered text. For instance, here's a transcript of a Linux (or macOS) console session:

Example:

<p>Command Entered:</p>
<p><kbd>ping example.com</kbd></p>
                                
<p>System Output:</p>
<p><samp>
Pinging example.com [93.184.216.34] with 32 bytes of data:
Reply from 93.184.216.34: bytes=32 time=20ms TTL=58
Reply from 93.184.216.34: bytes=32 time=22ms TTL=58
Reply from 93.184.216.34: bytes=32 time=21ms TTL=58
Reply from 93.184.216.34: bytes=32 time=19ms TTL=58
</samp></p>

Output:

Command Entered:

ping demo-example.com

System Output:

Pinging demo-example.com [93.184.216.34] with 32 bytes of data:
Reply from 93.184.216.34: bytes=32 time=20ms TTL=58
Reply from 93.184.216.34: bytes=32 time=22ms TTL=58
Reply from 93.184.216.34: bytes=32 time=21ms TTL=58
Reply from 93.184.216.34: bytes=32 time=19ms TTL=58





Tag Omission

The HTML <samp> element must have both start tag and end tag.

ATTRIBUTES

The <samp> element only has global attributes.

Frequently Asked Questions(FAQ)

What is the samp tag in HTML?
The <samp> tag in HTML is used to represent sample output from a computer program, system message, or command-line response. It is typically displayed in a monospace font to differentiate it from regular text.
What are the differences between kbd, samp and code in HTML ?
In HTML, <kbd>, <samp> and <code> are all inline elements which display text in monospace font, but they serve different purposes:
  • <kbd> - Represents keyboard input from the user..
  • <samp> - Represents system or program output.
  • <code> - Used to display code snippets.