HTML <samp> tag serves as a phrase tag that displays the output of a computer program or script within a web browser.
The text enclosed by the <samp> and </samp> tags will be displayed in the default monospaced font of the browser when viewed.
Note: The <samp> tag is not deprecated yet, but you can also use CSS property to achieve the same result.
Syntax
Example
<samp>Write sample output here.....</samp>
Following are some details regarding the HTML <samp> tag:
| Display | Inline |
|---|---|
| Start tag/End tag | Both Start and End tag |
| Usage | textual |
Example
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML samp tag</title>
<style>
body{
text-align: center;
}
</style>
</head>
<body>
<h2>Example of samp tag</h2>
<p>I am trying to install a software on my system but it is continuously giving an error message:
</p>
<p><samp>Error 5: Access is denied.</samp></p>
</body>
</html>
Output:
Attribute:
Tag-specific attributes:
The <samp> element does not have any particular attribute associated with it.
Global attribute:
The <samp> tag facilitates the utilization of global attributes within HTML.
Event attribute:
The <samp> tag enables the utilization of event attributes within HTML.
Supporting Browsers
| Element | Chrome | IE | Firefox | Opera | Safari |
|---|---|---|---|---|---|
<samp> |
Yes | Yes | Yes | Yes | Yes |