How do you show code on a website? Right now I define a bunch of CSS styles called Comment, Preprocessor, Keyword, etcetera. Then make a two column table, make the left column line numbers and and the right column each row has a line of code. Then I manually go through the code assigning CSS styles where appropriate. The problem is that this is tedious, especially for long pieces of code and it is not portable so if I need to change things it takes a long time. I am very new to website programming and have no idea where to start with this. Any help?

5 Years
Discussion Span
Last Post by pritaeas

Because I was challenged by a friend to make a C++ tutorial website and I am determined to win my challenge ;). Also how can I have hidden content (so you press a button and all of a sudden extra text appears.


Unfortunately I don't think I can help but I think you mean to display code like you would on this forum, in code tags, and I don't know how to do that (mainly because I have needed to do it so haven't looked into how it is done).

With regard to hidden content which shows on the click of a button that would need a mix of CSS and JavaScript - many tutorials on the web.

Sorry to have not been more help.


Ok, I guess I will stick to my tables of manually coloured syntax :( Thank you anyways.

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.