基于文本的网络浏览器
Text-Based Web Browsers

原始链接: https://cssence.com/2026/text-based-web-browsers/

## 基于文本的浏览器与现代HTML:日益扩大的差距 本文探讨了基于文本的浏览器(如Lynx和w3m)如何处理最新的HTML特性,发现支持严重不足。虽然这些浏览器在处理基本HTML方面表现出色,但较新的交互功能常常无法正确渲染,甚至根本无法渲染。 例如,`

` 披露小部件总是以展开状态显示,而`` 建议和`` 元素则仅仅显示为普通内容,忽略了它们原本的功能。Popover API和`inert` 属性也未得到支持,导致可访问性和交互方面的问题。 作者的主要 frustration 是对`hidden` 属性的持续忽略。与基于CSS的隐藏不同,在HTML中使用`hidden` *应该*可靠地隐藏内容,但基于文本的浏览器会忽略它,破坏了渐进增强技术。 最终,现代Web标准与基于文本的浏览器能力之间的差距正在扩大。虽然这些浏览器仍然可以用于测试基础HTML,但它们无法适应的事实表明,随着Web的发展,它们可能会逐渐失去 relevance。

最近的 Hacker News 讨论集中在文本浏览器在现代网络技术面前的可行性。链接的文章讨论了使用文本浏览器,但评论者普遍认为这是一场注定失败的战斗。 虽然网络在技术上可以支持文本,但持续追求更丰富、更复杂的功能——以及 JavaScript 密集型单页应用程序的普及——使得良好的文本浏览体验越来越不可能。试图简化网站通常会导致功能损坏。 这场讨论凸显了对网络臃肿的沮丧,并建议关注替代协议,如 Gemini,它专为轻量级内容设计,并且已经开始流行,作为比试图将现代网站强行塞入纯文本格式更现实的解决方案。最终,人们普遍认为网络的走向使得支持文本浏览变得不可持续。
相关文章

原文

Before I start, let me get two things out of the way:

  • In this article I’m not going to include the admittedly cool browsh, because it only works by utilizing Firefox under the hood. When I say text-based, I’m talking about old-school browsers like ELinks, Lynx or w3m. These are also the three browsers I’ve used to test everything described below.
  • The whole article ended up being a rant about how text-based browsers deal with features that got added to HTML. Or more like, how they neglect dealing with said features.

Do text-based web browsers still matter?

Well, I won’t be the judge of that. I like them, I have them installed, and I test every project I create in them. But they are not what I use to surf the web.

Speaking of testing your creations, here’s the good news: If your project has a solid HTML foundation that you then progressively enhance with CSS and JS, you are off to a great start.

How did HTML evolve in recent years?

While CSS is the star of the show when it comes to new features, HTML ain’t stale either. If we put the long-awaited styleable selects and Apple’s take on toggle switches aside, there’s a lot readily available cross-browser.

But here’s the thing: Whenever we say cross-browser, we usually look at the big ones, never at text-based browsers. So in this article I wanna shed some light on how they handle the following recent additions.

How do text-based web browsers handle modern HTML?

When viewing a web page in a text-based browser, you essentially get plain HTML, no CSS, no JS. There is some “styling”, a result of the elements’ semantics, but don’t expect anything fancy, we are down to colors, indentation, and centered text.

It reminds me of what the browsers we are used to give us when they show unstyled HTML—well, HTML with the browser default styles, to be exact. That in turn reminds me of CSS Naked Day.

Text-based browsers work well with good old HTML. Said recent additions however are a bit more nuanced (e.g. interactive), so let’s talk about them individually.

Details

Disclosure widgets are simple interactive elements we no longer need JS for. When <details> are closed, only their <summary> is shown.

Text-based browsers have no clue what disclosure widgets are, so they always show the whole <details> content, meaning you always get the open state. This way things can get verbose, but in essence it’s okay.

Verdict: Acceptable.

Data lists

Data lists can be used to add suggested values to an input field. In my tests they have been ignored entirely, Lynx even mentions that it encountered “bad HTML”, probably because it expects <option> only in a <select> parent. At least no browser rendered the options on the screen, they simply fall back to a plain <input> field, which is better than nothing. Side note: I’ve been told data lists have accessibility issues, so …

Verdict: Whatever.

Dialogs

Yes, HTML can do modal and non-modal dialogs, and even alert dialogs, all thanks to the <dialog> element. Initially we needed JS to toggle their visibility, but with the help of the Popover API (see next chapter) we can now even get most of it done in plain HTML.

Alas, once again there is no support in text-based browsers, so you’ll end up seeing all dialog content, as if they had their open attribute set. Consequently, there’s no awareness of a form’s method="dialog" nor a submit button’s formmethod="dialog", so in both cases the form action is triggered.

Verdict: Problematic.

Popovers

The Popover API is probably my favorite new feature, but only if you stick to regular web browsers.

Given that dialogs are a type of popover, it’s no surprise that nothing works, and once again all popover content gets dumped onto the screen.

By now I think you get the idea, so I won’t even talk about the Invoker Commands API at this point.

Verdict: Most likely problematic.

Inert content areas

A modal dialog makes the rest of the page inert, so we don’t have to do it. But with the global inert attribute we can do this manually too, if we need to make certain parts of the DOM unreachable.

Sure enough, text-based browsers will happily let you access interactive elements inside an inert content area.

Verdict: Bad.

Hidden content

We’re now approaching something that is not new at all, the global hidden attribute has been supported for over a decade. It allows us to hide content in the same way as display: none, but directly in HTML.

Adding support in text-based browsers has been discussed back in the day, but got rejected, hence it was never implemented. You’ll end up seeing all content marked as hidden. This is the primary reason why I started writing this article, and what enrages me the most. If I decide to hide content in HTML instead of CSS, I must have a very good reason, thus hidden content should not be visible in any browser! Certain progressive enhancement techniques work by hiding content in HTML and then making it visible via CSS or JS. That possibility goes out the window in text-based browsers.

Verdict: Epic fail. 😠 🤬

Visually hidden content

Just kidding, there’s still no native way in HTML to hide content visually, so we continue to rely on class names like .visually-hidden or .sr-only. No matter how they are named, they need to summon quite a few of lines of CSS to get things done. Whether there should be a native way is up for debate. Personally I would welcome a one-liner to achieve this, but it should remain in the domain of CSS.

However, if we had a way in HTML, text-based browsers would display such visually hidden content anyway, that is certain.

Verdict: To be continued.

Now what? What now?

Text-based browsers and modern HTML, no success story in sight. Given the progress we see in web technologies, the gap will only widen, so much so that w3m and its friends might fall into oblivion.

联系我们 contact @ memedata.com