1

I would like to display HTML source code in an HTML page. So I want it to look like it looks in your text editor. The source will be the complete source code, from the <html> tag to the end. So it needs to include the <head> and <body> with all styles in the <head>.

How would I do this?

2

1 Answer 1

2
<textarea name="Source Code"></textarea>

then set the value of that text area to

document.getElementsByTagName('html')[0].innerHTML

You might need to add the html tags again. But that should be no problem

Edit 2018

Someone upvoted this. I would highly recommend you take a look at https://highlightjs.org/. Its a very good solution for the stated problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.