How do we do computer output formatting using the tag in HTML?


We use <samp> tag to do computer output format. It is a phrase tag. It is used to define and identify the sample output of a computer program. It will display the text inside the <samp> element in monotype font.

Syntax

<samp>The text…</samp>

Example 1

Following is a simple example to explain the usage of <samp> tag in HTML −

<html> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <p><b>Pluralsight</b> is the technology workforce development company that helps teams know more and work better together with stronger skills, improved processes</p> <samp> Pluralsight, Inc. is an American privately held online education company that offers a variety of video training courses for software developers </samp> </body> </html>

Example 2

Another example to use this tag in html document is −

<html> <head> <title>Title of the document</title> </head> <body> <samp> <h2> HTML document</h2> <p>This is a paragraph.</p> <p>This is another paragraph</p> </samp> </body> </html>

Example 3

We can override the font style using the style sheet.

<html> <head> <meta charset="UTF-8"> <meta name="description" content="meta tag in the web document"> <meta name="keywords" content="HTML,CSS"> <meta name="author" content="lokesh"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> samp{ font-family: cursive; } </style> </head> <body> <p><b>Pluralsight</b> is the technology workforce development company that helps teams know more and work better together with stronger skills, improved processes</p> <samp> Pluralsight, Inc. is an American privately held online education company that offers a variety of video training courses for software developers </samp> </body> </html>

Updated on: 19-Oct-2022

147 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements