Open In App

When to use <samp> tag in HTML ?

Last Updated : 04 Mar, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The <samp> tag in HTML is used to define sample output from a computer program. It is typically used to represent text that is the output of a program or script. The <samp> tag is an inline tag and its content is rendered on the browsers in a monospaced font.

Syntax:

<samp> Sample output text </samp>

Example: The basic example of <samp> tag.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
    <title>Sample Output Example</title>
</head>

<body>
    <h1>Program Output Example</h1>

    <p>
        The Output of program is: 
        <samp>Sample Output</samp>.
    </p>
</body>

</html>

Output:

samp-output


Example 2: in this example, we will show an error by using <samp> tag.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
    <title>Sample Output Example</title>

    <style>
        samp {
            color: green;
        }
    </style>
</head>

<body>
    <h1>Program Output Example</h1>

    <p>
        The Output of program is: 
        <samp>Sample Output</samp>.
    </p>
</body>

</html>

Output:

sampu-output-color


Next Article

Similar Reads