Loading Please Wait...

Logo Lynxsia IT Solutions

HTML Computer Code Elements

Computer Code Elements

HTML supports various elements to display computer codes such user input, program output, variables definition, etc.

Computer code elements includes <code>, <kbd>, <samp>, and <var>

<code> Element

The <code> element defines computer code such as HTML, CSS, JavaScript, C, PHP, etc. The text inside <code> is displayed in default font of browser that is monospace.

Let's see with some example
					 
        
          <!DOCTYPE html>
          <html>
            <body>
              <code>
                function myFun(){
                  documnet.write('Hello World');
                }
              </code>
            </body>
          </html>
        
      

The <code> element ignores line break and whitespace, you can use <code> element inside <pre> to achieve this.

Let's see with some example
					 
        
          <!DOCTYPE html>
          <html>
            <body>
              <pre>
                <code>
                  function myFun(){
                    documnet.write('Hello World');
                  }
                </code>
              </pre>
            </body>
          </html>
        
      
<kbd> Element

The <kbd> element defines computer input such keyboard shortcuts. The text inside <kbd> is displayed in default font of browser that is monospace.

Let's see with some example
					 
        
          <!DOCTYPE html>
          <html>
            <body>
              <p>To copy text press: <kbd>CTRL + C</kbd></p>
            </body>
          </html>
        
      
<samp> Element

The <samp> element defines sample output generated from computer program. The text inside <samp> is displayed in default font of browser that is monospace.

Let's see with some example
					 
        
          <!DOCTYPE html>
          <html>
            <body>
              <samp>File uploaded successfully. Click Browse to upload more files.</samp>
            </body>
          </html>
        
      
<var> Element

The <var> element defines variables used in program, equations, etc. The text inside <var> is displayed in italic.

Let's see with some example
					 
        
          <!DOCTYPE html>
          <html>
            <body>
              <p>
               Aria of rectangle = <var>l</var> x <var>w</var>.
               Where <var>l</var> is length and <var>w</var> is width of rectangle.
              </p>
            </body>
          </html>
        
      

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved