Need feedback for technical documentation page and some questions

https://codepen.io/chleung510/pen/vYKgqyW

1.) I made a C++ documentation page and used tag to show my C++ codes(sources codes shown below), but ended up getting error messages shown below. I found that “<” and “>” are special characters for html codes. So is it ok to use < as “<” and & rt; as “>” in my c++ codes even my codes are not in html?

2.) Also, what is the best way to show the line numbers for my C++ codes.

3.) Finally, I wonder if it is always necessary to quote where I copy the contents from even it is technical contents?

Thanks in advance!

Source Code:


Error messages:



Anyone can help with one of the problems I mentioned?

In html if you write stuff like this std::cout << "Hello World!"; the computer does not know how to interpret this part <<. So that is why you are getting errors.

You need to use HTML entities for less than and greater than symbols. Those error messages are telling you how to write those symbols. You can also learn about them here.

I personally think the way you are doing it works but maybe someone else on the forum has another suggestion.

You should always credit your sources.

Also, please do not have inline styles. Put that in your css.
ex. style="text-indent:40px"

1 Like

I don’t really recall the page requirements by heart, but id you want to show some code, with syntax highlight, line number and all, probably the most common method you’ll find is a screenshot from your own editor.

In general, i see many blog posts either showing a small snippet inside a <pre> block, or if the content is big it’s a screenshot image of their editor :slight_smile:

Hope it helps.

2 Likes