- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <samp> Tag
HTML Tags
HTML <samp> Tag
The samp tag marks text that a computer program printed: an error message, a command's result, a log line. It shows in a monospace font, like code, but it means "this came out of the machine".
It belongs to a small family: code for code you write, kbd for keys you press, and <samp> for what the computer answers.
Syntax
html
<samp>sample output</samp>It has no attributes of its own, only the global ones.
Example
html
<!DOCTYPE html>
<html>
<head>
<title>HTML samp Tag Example</title>
</head>
<body>
<h2>HTML <samp> Tag Example</h2>
<p>Computer output may look like this:</p>
<p><samp>Error: File not found.</samp></p>
<p>Or a command result:</p>
<p><samp>Ping successful — 0% packet loss.</samp></p>
<p>Another example:</p>
<p><samp>Login failed. Try again.</samp></p>
</body>
</html>The three messages, "Error: File not found.", the ping result and "Login failed. Try again.", appear in a monospace font, like text on a terminal screen.
All three together
A command, its key and its output
html
<p>Type <kbd>npm -v</kbd> and press <kbd>Enter</kbd>. You should see
something like <samp>10.2.4</samp>.</p>Good to know
<samp>has no default style other than the monospace font. Give it a background or a color with CSS if it needs to stand out.- For many lines of output, put
<samp>inside a<pre>so the line breaks are kept. - An error message shown by your own website to its users is not
<samp>; that is normal text.<samp>is for quoting output in documentation.
HTML <samp> Tag exercises
Mark program output
Write this paragraph with done marked as output of a program: It prints done and stops.
Result
Check your answer to see it here.
