Sometimes it is necessary to place a tag on a web page in such a way that it does not perform the function assigned to it, but is itself displayed on the screen. This may be required, for example, when compiling textbooks on the HTML language, as well as to provide examples of code snippets in this language.
Instructions
Step 1
The quickest way to render an example HTML code on a web page is to use a tag. After it, place the piece of text that you want to show, and it will be displayed unchanged, along with the tags placed in it. Then position the closing tag. This method has two drawbacks: firstly, it is not standard, which means that the page with it may not pass validation, and secondly, it will not be perceived by old browsers that support the HTML specification below 4. They will not have tags displayed on the screen and executed. Note that the tag
which is standard and supported by a large number of browsers, cannot be used instead because it does not disable command execution.
Step 2
A fairly universal way to place a piece of text with tags on a web page is to insert it as an image. To do this, start any raster graphics editor, create a new picture of a sufficient size in it, and then turn on the tool for typing (usually the button with the letter A or T is used for this). Move the mouse arrow to the upper left corner of the image, press the left key, and then enter a piece of text or paste it from the clipboard using the Ctrl-V keys. Crop the image (how to do this depends on what editor you are using, for example, in GIMP, for this you need to select a fragment, and then select the menu item "Image" - "Crop selection"). Save the result to a GIF, PNG or.jpg
Step 3
Place the created image in the same server folder as the HTML file into which you are going to paste it. Then place the following tag in the right place of this file:, where image-name.extension is the name of the image file along with the extension. If for some reason you placed the image in a different folder as the HTML file, place the full path to it instead of the image file name. Please note that the user will not be able to view the fragment of HTML-code inserted in this way if the display of images is disabled in his browser.
Step 4
Even more universal is the way of placing HTML tags on the page, which consists in using their codes instead of characters. To do this, use the following codes: instead of ->. This technique works in almost all browsers, regardless of how they are configured.