+ 1

How do we write a programing code as text to your web page?

13th Feb 2017, 10:24 AM
Emmanuel Nuotah
4 Answers
+ 2
As suggest put your programming code within <code> </code> tags. You may use <pre>..</pre> tags to retain whitespace such as spaces, tabs and returns keys.
13th Feb 2017, 11:44 AM
à€Šà„‡à€”à„‡à€‚à€Šà„à€° à€źà€čà€Ÿà€œà€š (Devender)
à€Šà„‡à€”à„‡à€‚à€Šà„à€° à€źà€čà€Ÿà€œà€š (Devender) - avatar
+ 2
<code> is the tag semantically adapted, but for styling, you may want to reproduce behaviour of <pre> tag ( which keep spaces, line-breaks and don't arbitrary break lines ), as well as escape special Html characters ( at least '<' and '&' by respectively '&lt;' and '&amp;' ), or a code like: <code><test>test</test></code> ... will not be outputed as expected ( the <test> tags disappears ;) ) So I suggest to write ( inlined css only for providing example ): <code style="white-space:pre">&lt;test>test&lt;/test></code> Wich means some preprocessing. Also if you want have syntaxic colour, you must preprocess you code to style it: some library can be found to help you ^^
14th Feb 2017, 3:34 AM
visph
visph - avatar
+ 1
Do you want to link to a web page?
13th Feb 2017, 10:40 AM
Kolapo Imam
Kolapo Imam - avatar
+ 1
If its in another language use code tags <code>code here</code>
13th Feb 2017, 11:16 AM
Andre van Rensburg
Andre van Rensburg - avatar