Hi all.

I have a website that I'd like to post my C++ endeavours to. I want to make it so the source code can be viewed on my website with the correct colour coding, etc.
I'm relatively new to CSS and XHTML. I've been using Notepad++.
How do I go about doing this?

Thanks in advance for any help offered.

5 Years
Discussion Span
Last Post by Tinnin

The most basic solution is to wrap the code in pre tags to preserve the formatting. But be careful with C++, because you'll need to remember to escape certain characters like angle brackets and the & operators, otherwise they'll be stripped when the browser can't interpret them as HTML. It's annoying looking at naively posted code and seeing #include with the actual header missing. ;)

You could also wrap the code in HTML code tags. I'm not sure off the top of my head if that will fix the stripping problem or not though, it's something to test.

If you need highlighting as well then there are a number of syntax highlighting options out there such as Google Code Prettify or SyntaxHighlighter.


Thanks thewebhostingdi. I may do so in the future so I'll bear it mind. Cheers.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.