@Ron_Bowman
Canvas does not convert tabs to spaces for you. It's a text editor, not a programmer's editor, and just treats a tab as a U+0009 (character code 9). There is a tab-size CSS property that defaults to 8, but it would control it. You cannot enter that into your HTML, though, as it is not supported by the Canvas HTML Whitelist.
It appears supported while you're using the Rich Content Editor, but it is stripped out when saved.


but when you save it, it becomes

The reliable way to get the desired indenting is to use spaces rather than tabs, although that may break people's ability to copy/paste functioning code (probably not a high priority for a quiz).
Most Code Editors have an option for configuring this or there are normally online code formatters that will allow you to paste your code and then beautify or format it and many have configuration settings.
For example, I use the Online JavaScript Beautifier that supports JavaScript, HTML, and CSS. One of the options at the top of JavaScript is to "Indent with 2 spaces"

And that can be changed to other flavors

That's just the one I use most often because Eclipse (my IDE) doesn't format anything with ES6 arrow functions, but they exist for other languages.
You may also be able to work with your Canvas Admin to install a code highlighter library and then you can use Prism, highlight, or some other JavaScript library. They differ in how they're implemented (some use classes some use code as well as pre).
The Canvas Admin may be hesitant to do this as it would get loaded for every student throughout Canvas for the use of just a few and that's an overhead they may not want to do. If your computer science classes were all in a sub-account, it could be added at the sub-account level and not affect as many people.
One thing to watch out for when you do that is whether it works with the mobile apps. I don't have extensive testing there, but the worst should be that it just doesn't do anything.
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.