This method is for advanced users because it requires more work and does not always work as intended.
It is suitable for users who are still using the old Classic editor and want to display code without using a plugin.
First, you need to pass your code through an online HTML entities encoder tool. It will change your code markup to HTML entities, which will allow you to add the code and bypass the WordPress cleanup filters.
Now copy and paste your code into the text editor and wrap it around <pre> and <code> tags.
Syed Balkhi https://www.wpbeginner.com/wp-tutorials/how-to-easily-display-code-on-your-wordpress-site/
For code, I was just using <code>, but it never formatted properly. Using <Pre> and a HTML encoder solves that.