Here's what it looks like...
The CSS is very simple:
To explain this - the :checked pseudo-class applies when the checkbox is selected/checked and the '+ pre' part is an adjacent selector for the pre element. Together this means 'when there is a checked checkbox next to a pre element'.
Now the HTML is like this...
You can also replace the pre element with just about anything else, as long as the style is updated and you use the new element after the checkbox.