C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
HTML Computer codeWhen we are programming, sometimes it is mandatory to show the Output result, error message, or coding part to user on a webpage. Hence to solve this issue HTML uses different tags for the user inputs, codes, programs, etc. With the help of these tags, you will be able to write codes to display on your webpage. Following is a list of some tags which are used in HTML for this task.
HTML <code> elementIt is used to represent some programming code on your website. The content written between Example: <!DOCTYPE html> <html> <body> <h2>Computer Code</h2> <p>This is a programming code:</p> <code> x = 5;<br> y = 6;<br> z = x + y; </code> </body> </html> HTML <kbd> ElementIt is used to represent user input, keyboard input, voice command etc. Text written within <kbd>.....</kbd> tags is typically displayed in the browser's default monospace font. Example: <!DOCTYPE html> <html> <body> <h2>The kbd Element</h2> <kbd>This is how content written within kbd element looks like.</kbd></p> </body> </html> HTML <samp> ElementThe HTML <samp> element is used to represent a program's output. Text written within samp element is typically displayed in the browser's default monospace font. Example: <!DOCTYPE html> <html> <body> <h2>The samp Element</h2> <samp>This is how the content within samp element looks like. </samp> </body> </html> HTML <var> elementThe HTML <var> element is used to define a variable. The variable could be a variable in a mathematical expression or a variable in programming context. Example: <!DOCTYPE html> <html> <body> <h2>The var Element</h2> <p>This is a famous formula: <var>E</var> = <var>mc</var><sup>2</sup>.</p> </body> </html> HTML <pre> elementThe <pre> element defines preformatted text, which displays the content within it in a fixed-width font. It keeps the content into its original format and ignores all formatting. Example: <!DOCTYPE html> <html> <body> <h3>Example of pre tag</h3> <pre> This is content written within pre tag, and pre tag will ignore all spaces, break lines, and will display the content as in original format. </pre> </body> </html>
Next TopicHTML Entities
|