Best practice for writing source code
-
Hi,
in my blog I have to write a couple of source code line, as in https://entrevistandodados.wordpress.com/2017/05/11/agregando-valores-na-base-de-doacoes-para-campanhas-eleitorais/.
The way I managed to this was using the HTML editor, and writing like
SELECT bla bla;</span>However is annoying writing all of this for each code. Something like
<span class=”code”>SELECT bla bla;</span>
would be better, but I do not know how to define my own CSS styles in WordPress (I’m using the as-service version).
I also tried the “preformatted” paragraph style in the visual editor. But it was not nice, since it creates awful horizontal scrolls.
So, how do you guys think would it be the best practice for writing source code on WordPress posts? Am I on the right way?
Thank you!!!!
Leonardo Leite
The blog I need help with is: (visible only to logged in users)
-
Correcting:
The way I managed to this was using the HTML editor, and writing like
<span style="color: #0000ff;"><code>SELECT bla bla;</code> </span> -
Hi there, take a look at the Posting Source Code section of our Code support page for more information.
-
Is it possible to use the code tag and order it to wrap the code within?
It it possible to bold text within the code tag?
Thank you!!!
-
Hi, yes you can use the code tags
<code>code here</code>
You cannot bold something with code tags as browsers, when they see code tags, do not render anything they find between the code tags, they just apply whatever special styling there might be in the CSS, or absent of that, they make the choice on styling. I don’t know if Goran has any styling for code tags. most themes do typically from my experience, but not all. You can of course add your own styling as well.
- The topic ‘Best practice for writing source code’ is closed to new replies.