I want to show code in a html page. The code may be written in any language.The output should be as follows:
Asked
Active
Viewed 509 times
-3
-
2Ok. What's your question? Something more specific than "how do I do this?" I hope. – Carcigenicate Nov 14 '16 at 12:44
-
1This question has already been answered endless times. Take a look here for example: http://stackoverflow.com/questions/2820453/display-html-code-in-html – arkascha Nov 14 '16 at 12:45
-
How to implement this? – RidwanulHaque Nov 14 '16 at 12:45
-
Google e.g. `html code highlighting`. It'll give you a number of solutions, e.g. https://highlightjs.org. Even a query for `I want to show code in html page` gets good results - always remember to Google first. – Pekka Nov 14 '16 at 12:46
1 Answers
1
All you need to do is write up some CSS (or use inline styling) for the grey background div and then use <span> tags to color the text inside of a <p> tag.
Here is some info on span tags: http://www.w3schools.com/tags/tag_span.asp
Also, you have to replace some characters in the code you want to display. You should replace < with <, and replace > with >. You can put all of that inside of a <code> tag if you would like, but I don't think its necessary.
If you would like it to automatically be colored and formatted and such, then you may need some JavaScript or something, but if it is a static HTML page, then you should just stick with the basics.
Evan
- 56
- 8