So I have a codepen for my technical document, and have a <pre> and <code> code block, but can’t seem to figure out how to center it. I’ve tried putting a div container around the <pre>, as suggested here in this stack overflow discussion:
However, I can’t seem to center this within the container area.
Hi @HanSolo0001,
Have you tried removing the whitespace around the content of <code>? It seems to be centering it for me. Is that what you’re trying to do?
Mmm, it still seems to be a whitespace issue. I’ve removed it on HTML Elements and it seems to be centered even on a smaller width. I haven’t removed it on the HTML Attributes and it goes off screen.
If I correctly understood your problem, you should remove the text-align: center on your body selector in your CSS file.
Once you did that, you should format your “code” and you should
also remove all the whitespaces inside the pre code HTML blocks.