The HTML <samp> tag is used to represent a small section of text that is intended to be displayed as computer output or code snippet. The text within the <samp> tag is typically rendered in a fixed-width font and enclosed in a box.
Here’s how to use the <samp> tag:
Syntax:
<samp>Text</samp>
Attributes:
– `id`: Specifies a unique identifier for the element.
– `class`: Specifies one or more classes for the element, which can be used for styling.
– `style`: Specifies inline CSS styles for the element.
– `title`: Specifies additional information about the element.
Example:
<samp>Output goes here</samp>
Output:
<samp>Output goes here</samp>
Styling the <samp> tag can be done using CSS, just like any other HTML element. Here’s an example of how to style the <samp> tag:
Example CSS:
samp {
display: block;
margin: 10px 0;
padding: 10px;
background-color: #eee;
font-family: monospace;
}
In this example, we’ve set the display property to block, which means that the <samp> tag will take up the full width of its container. We’ve also added some padding and a background color to make the text within the <samp> tag more readable.
That’s the basics of the <samp> tag! Use it whenever you want to display computer output or code snippets on your website.