{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreign2ephlltimyfjivweu6ijrllhdz4x3i3b6j6adqptw6mvl5hsje",
    "uri": "at://did:plc:vyjlfm46mfv6u4vjp6qtrfx2/app.bsky.feed.post/3mhy7hwo4lgi2"
  },
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreidg2k33tiuupnstmiowh7hyyvtsbe3gyhfygiytrzynysnhoctrxi"
    },
    "mimeType": "image/jpeg",
    "size": 81260
  },
  "path": "/articles/preformatted",
  "publishedAt": "2026-03-26T06:30:00.000Z",
  "site": "https://thedailywtf.com",
  "tags": [
    "CodeSOD",
    "Download Free Guide Now!"
  ],
  "textContent": "**Amity** sends us a \"weird\" replacement, and I regret to inform you, it's not as weird as it should be.\n\n\n    $body = str_replace(['<pre><code>', '</code></pre>'], ['<pre>', '</pre>'], $body);\n\n\nThis PHP code scans through a string containing HTML and replaces all the `<pre><code>.../<code></pre>` tags with just `<pre></pre>`. And yes, that's a weird thing to do; these mean different things, after all. `pre` tells us the text is preformatted and things like extra whitespace and line breaks should be respected. `code` tells us the text represents some sort of code. Usually, that involves respecting the formatting, but it also generally involves rendering in a monospace font.\n\nAnd this touches upon one of my complaints about this very site. A complaint I don't complain about much, because I could easily fix it, and also it doesn't bother me that much, but also, I don't want to be maintaining our little homegrown CMS more than I have to, so I haven't done it.\n\nQuite some time ago, we did a redesign here. It was fairly necessary, as the site old 100% didn't work on mobile devices. At the time, one habit was _en vogue_ amongst web developers: clear all the formatting rules from the default browser stylesheet and replace them with your own. I can sympathize with that, I suppose. It's certainly one way to deal with cross browser rendering quirks: burn everything to the ground and build up from scratch. You'll still have cross browser quirks, but they'll all be your fault, and your fault alone. And another \"quirk\" that showed up in that rebuilding, and a quirk I've seen on a depressing number of other sites: make `pre` content be in monospace.\n\nFor some reason I don't fully understand, there was a brief period in CSS styling where people willfully collapsed the distinction between `pre` and `code`, and just turned them into the same thing. I'm admittedly a bit of a semantic snob (HTML is a DATA format not a PRESENTATION format, it's still SGML to me).\n\nIn any case, this doesn't impact you, our dear readers, who instead get a sometimes confounding Markdown comment box with bad editing support. But I post articles here in pure HTML, and while I rarely need a `pre` tag, every once in awhile, the default site stylesheet throws me off.\n\n[Advertisement] **Plan Your .NET 9 Migration with Confidence**\nYour journey to .NET 9 is more than just one decision.Avoid migration migraines with the advice in this free guide. **Download Free Guide Now!**",
  "title": "CodeSOD: Preformatted"
}