HTML <samp> Tag

Last Updated : 28 May, 2026

The <samp> tag in HTML is used to display sample output from a computer program or system. It is generally shown in a monospace font to distinguish output text from normal content.

  • <samp> tag represents sample program or system output.
  • It is commonly used to display command results or console output.
  • Browsers usually display <samp> text in a monospace font.
  • It improves readability and semantic meaning of output text.

Syntax: 

<samp> Contents... </samp>

Example: Using the <samp> tag to display sample output or code. Here, the text "A computer science portal for Geeks" is rendered in a monospace font, indicating sample output.

HTML
<!DOCTYPE html>
<html>

<body>

    <h1>GeeksforGeeks</h1>
    <h2>&lt;samp&gt; Tag</h2>
    <!-- html <samp> tag is used here -->
    <samp>A computer science portal for Geeks</samp>

</body>

</html>
Comment