HTMLCODE

HTML Code

Insert Code into an HTML Web Page

You can add code into an HTML Web page with a few simple steps using the <pre> and <code> HTML Tags.

In addition to the two HTML tags you will also want to define a CSS Style for the two tags to make them show up as expected on your page.

Creating CSS Style to show the code

  
    <style>
       pre code {
          background-color: #eee;
          border: 1px solid #999;
          display: block;
          padding: 10px;
        }
    </style>  
   

Wrap your Code with the formatting tags "pre" and "code" as follows:

  
    <pre>
      <code>
         // My Comment here
         public String answerWithAmazingThings(String questions) {
            return "The Wizard is Busy Today";
         }
      </code>
    </pre>
  

Generates this HTML output

  
 // My Comment here
 public String answerWithAmazingThings(String questions) {
    return "The Wizard is Busy Today";
 }
  

That Fast and Simple!