WordPress – Code snippet display

We have had a few people ask us how we wrap our code snippets on this site with the yellow background. This is a very simple piece of code using the <pre> function. You can customise it as much as you like with different fonts, sizes, colours and borders but this is our default to […]

Wordpress Code Snippet Display
We have had a few people ask us how we wrap our code snippets on this site with the yellow background. This is a very simple piece of code using the <pre> function. You can customise it as much as you like with different fonts, sizes, colours and borders but this is our default to get you started:
<pre style="border: solid 1px blue; color: black; margin: 10px; padding: 10px; background: #FFFFB3;">SAMPLE TEXT</pre>
where:
  • border: solid 1px blue = solid border with 1px in size and blue in colour
  • colour: black = font colour
  • margin: 10px = margain on either side of at least 10px
  • padding: 10px = padding of 10px
  • background: #FFFB3 = background colour (in our case yellow)
  • SAMPLE TEXT = Text to display in the box
All you need to do then is change the sample text to whatever you want to display in the code snippet box and post the code into your “Text” editor, do not use the “Visual” editor as it will screw up the coding.
🛠️

Gear We Recommend

A few general tech accessories worth having alongside this.

Browse our General Tech Accessories picks on Amazon

As an Amazon Associate, TechyGeeksHome earns from qualifying purchases.


Discover more from TechyGeeksHome

Subscribe to get the latest posts sent to your email.

Andrew Armstrong

Andrew Armstrong is a UK-based IT professional with 26+ years of hands-on experience in Windows, Windows Server, SCCM/ConfigMgr, Active Directory, PowerShell, and enterprise infrastructure.

He founded TechyGeeksHome in 2010 and has published over 1,500 practical guides covering real-world IT problems and solutions. When not solving IT problems,

Andrew develops free Windows utilities including Ultimate Settings Panel, which has been downloaded over 850,000 times.