How to display html as plain text without changing .html

I teach a GUI and use web pages, not PP. I am starting to add HTML5 and CSS instructions to the course. for file style_by_kind.html
CSS example style_by_kind.html

when a student clicks on a link, obviously launches the file and displays it. students can use “save as” in their browser to get a copy for themselves.

I want to show the source as text so that I can lecture on html HTML code. The link runs the code. Physically, including the file, the html code is run. not applicable, only output is not displayed, comment Due to constant updates, it is undesirable to copy a file with a different file type extension, and it is impossible to "output" from html.

Any simple syntax that should be placed in the link or around the physical copy, so the student simply sees the plain text, will be very grateful.

+3
source share
3 answers

Depending on how the files are served, you can set the ContentType header as text / plain, but I suspect that most browsers will still cheat on the MIMETYPE of the file and display it as html.

Using the tag <pre>as a @ hamlin11 clause is a good idea.

0
source

I would suggest changing the extension of the html file to txt.

Therefore, when you view the txt file, it will still be displayed in the browser with the same code.

0
source
Use <plaintext></plaintext> tags

For example, "This is a lesson on bold tags: <plaintext><b>Bold Text</b></plaintext> will     display as <b>Bold Text</b>"
-1
source

All Articles