Wordpress SEO Expert

Improve your Google ranking with 24-year experienced SEO professional Peter Mahoney

  • SEO Overhaul
  • SEO Campaign
  • WP Support
  • Blog
    • SEO Emails
  • Praise

Displaying code snippets easily

February 21, 2013 by Peter Mahoney

With the new site and all I’ve some CSS to get through.

I wanted to make the “pre” element work as a code snippet display for me, and needed a fix to get it to wrap text (since the “width” attribute has been defunct for some time).

Here’s the solution!

pre {
 background-color: #F2F2F2;
 padding: 5px 5px 5px 5px;
 white-space: pre-wrap;       /* css-3 */
 white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
 white-space: -pre-wrap;      /* Opera 4-6 */
 white-space: -o-pre-wrap;    /* Opera 7 */
 word-wrap: break-word;       /* Internet Explorer 5.5+ */
}

Filed Under: Nerd-stream, Uncategorized Tagged With: code, CSS, snippets

Comments

  1. Peter Mahoney says

    March 1, 2013 at 12:33 pm

    Sadly with WordPress in particular this isn’t much help, because php code still gets executed rather than displayed.

    I do recommend “SyntaxHighlighter Evolved”, a plugin that makes displaying code pretty damn simple.

Get FREE Wordpress SEO tips!

I send regular newsletters with WordPress SEO expert-level tips. Sign up to get them, along with my FREE e-book “Ongoing SEO Success”.

Did I mention they’re free!

Subscribe for free

Praise

I have over 2,500 5-star feedback reviews (and I’ve never received less than the full five.)

Here’s just one example, from Mike who runs Costello Entertainments:

Migration, Hosting, SEO and Speed Work on our new website all completed quickly and efficiently and Peter was most helpful in fixing an issue with a Popover on the site as well. If you’re thinking about asking Peter to do a job for you or hesitating, JUST DO IT! – He knows programming and the internet inside out, he’ll get the job done for you professionally, with a smile. I wish I could call a plumber or a tradesman to do the jobs I can’t do myself with the same level of confidence.
Read a lot more.

Recent Blogs

  • Thanks WordPress SEO expert for all your work.
    I feel like you are my guy for all my SEO. I did want to ask you if I need to get someone to write my Blog ...
  • Can the description show the Product Short Description
    Hi Peter SEO Expert :), Hope you’re doing well and having a good summer. Had this message from a client ...
  • Don’t just search for yourself!
    This is actually a stock answer I send people pretty often. I’m regularly asked about the difference ...
  • SEO doesn’t shouldn’t your site’s front-end
    On my SEO Emails section (where I share helpful responses to commonly asked queries) I recently shared a not ...

Legal

  • Terms and conditions
  • Privacy policy
  • Disclaimer

Also read

  • Payment information

RSS

Peter Mahoney, WordPress SEO expert blog

Recent Posts

  • Thanks WordPress SEO expert for all your work.
  • Can the description show the Product Short Description
  • Don’t just search for yourself!
  • SEO doesn’t shouldn’t your site’s front-end
  • Cumulative Layout Shift (CLS) for SEO & Speed

© Copyright 2023 Wordpress SEO Expert · All Rights Reserved · Site by Peter Mahoney