HTML Computer Code


HTML includes various elements to define both user input and computer code.



HTML <kbd> For Keyboard Input

The HTML <kbd> element is used to specify keyboard input. The content inside appears in the browser's standard monospace font.


HTML <samp> For Program Output

The HTML <samp>tag is used to show example results from a computer program. The text inside appears in the browser's default monospace font.


HTML <code> For Computer Code

The HTML <code> element Is employed to specify a segment of computer code. The content within is shown using the browser's default monospace font.


HTML <var> For Variables

The <var> element  in HTML is used to define a variable in programming or math. The text inside is usually shown in italics.


Chapter Summary

  • The <kbd> element shows keyboard input
  • The <samp> element shows sample output from a computer program
  • The <code> element  shows a piece of computer code
  • The <var> element shows a variable in programming or in a mathematical expression
  • The <pre> element shows preformatted text