等宽网页
The Monospace Web

原始链接: https://owickstrom.github.io/the-monospace-web/

本文介绍了一种称为“等宽网页”的独特网页设计概念,它利用等宽字体来提高可读性和一致性。 作者的动机在于创造一种视觉上令人愉悦的体验,让人想起终端屏幕,同时保持功能性。 内容基于一个简单的 Markdown 文件,利用 CSS 和 JavaScript 转换为交互式网页,能够针对移动设备进行缩小。 主要功能包括使用 HTML 进行布局、语义上正确的编码以及遵守 20 世纪 70 年代的标准。 其他方面包括列表、表格、表格和 ASCII 绘图。 等宽图表、消息传递示例和多媒体集成是其他亮点。 总的来说,作者邀请用户探索、适应或为这个实验项目的进一步发展做出贡献。

在排版方面,研究表明,按比例间隔的字体可以提高数字和印刷文本的可读性。 由于字母之间的对比度得到改善,这些字体提供了更高水平的易读性。 例如,1983 年《Human Factors》杂志上发表的一项研究发现,在调整任务复杂性、字体样式和字体大小等变量时,比例字体和等宽字体之间的阅读时间没有显着差异。 相反,Belde I.P.、Pastoor S. 和 Schwarz E 在 1983 年进行的另一项研究表明,比例字体的阅读效率略有提高,尽管差异可以忽略不计。 最近的研究表明,较大的文本和字符之间的间距增加可以提高患有或不患有阅读障碍的人的阅读速度。 此外,在选择字体时还应考虑信息保留、对视觉呈现的情感反应以及用户偏好等因素。 此外,虽然可以通过调整文本和提供可选连字符的功能来扩展现有的代码编辑器,但实时实现仍然具有挑战性。 最后,某些字体选择和配置似乎会影响在线内容的美感,无衬线和衬线字体通常被认为比等宽字体更具视觉吸引力,适合扩展阅读。
相关文章

原文
The Monospace Web

Introduction

Monospace fonts are dear to many of us. Some find them more readable, consistent, and beautiful, than their proportional alternatives. Maybe we’re just brainwashed from spending years in terminals? Or are we hopelessly nostalgic? I’m not sure. But I like them, and that’s why I started experimenting with all-monospace Web.

On this page, I use a monospace grid to align text and draw diagrams. It’s generated from a simple Markdown document (using Pandoc), and the CSS and a tiny bit of Javascript renders it on the grid. The page is responsive, shrinking in character-sized steps. Standard elements should just work, at least that’s the goal. It’s semantic HTML, rendered as if we were back in the 70s.

All right, but is this even a good idea? It’s a technical and creative challenge and I like the aestethic. If you’d like to use it, feel free to fork or copy the bits you need, respecting the license. I might update it over time with improvements and support for more standard elements.

The Basics

This document uses a few extra classes here and there, but mostly it’s just markup. This, for instance, is a regular paragraph.

Look at this horizontal break:


Lovely. We can hide stuff in the <details> element:

A short summary of the contents

Hidden gems.

Lists

This is a plain old bulleted list:

  • Banana
  • Paper boat
  • Cucumber
  • Rocket

Ordered lists look pretty much as you’d expect:

  1. Goals
  2. Motivations
    1. Intrinsic
    2. Extrinsic
  3. Second-order effects

It’s nice to visualize trees. This is a regular unordered list with a tree class:

  • /dev/nvme0n1p2

    • usr
      • local
      • share
      • libexec
      • include
      • sbin
      • src
      • lib64
      • lib
      • bin
      • games
        • solitaire
        • snake
        • tic-tac-toe
      • media
    • media
    • run
    • tmp

Tables

We can use regular tables that automatically adjust to the monospace grid. They’re responsive.

Name Dimensions Position
Boboli Obelisk 1.41m × 1.41m × 4.87m 43°45’50.78”N 11°15’3.34”E
Pyramid of Khafre 215.25m × 215.25m × 136.4m 29°58’34”N 31°07’51”E

Note that only one column is allowed to grow.

Forms

Here are some buttons:

And inputs:

Grids

Add the grid class to a container to divide up the horizontal space evenly for the cells. Note that it maintains the monospace, so the total width might not be 100%. Here are six grids with increasing cell count:

If we want one cell to fill the remainder, we set flex-grow: 1; for that particular cell.

ASCII Drawings

We can draw in <pre> tags using box-drawing characters:

╭─────────────────╮
│ MONOSPACE ROCKS │
╰─────────────────╯

To have it stand out a bit more, we can wrap it in a <figure> tag, and why not also add a <figcaption>.

┌───────┐ ┌───────┐ ┌───────┐
│Actor 1│ │Actor 2│ │Actor 3│
└───┬───┘ └───┬───┘ └───┬───┘
    │         │         │    
    │         │  msg 1  │    
    │         │────────►│    
    │         │         │    
    │  msg 2  │         │    
    │────────►│         │    
┌───┴───┐ ┌───┴───┐ ┌───┴───┐
│Actor 1│ │Actor 2│ │Actor 3│
└───────┘ └───────┘ └───────┘
Example: Message passing.

Let’s go wild and draw a chart!

                      Things I Have
                                              
    │                                     ████ Usable
15  │
    │                                     ░░░░ Broken
    │
12  │             ░            
    │             ░            
    │   ░         ░              
 9  │   ░         ░              
    │   ░         ░              
    │   ░         ░                    ░
 6  │   █         ░         ░          ░
    │   █         ░         ░          ░
    │   █         ░         █          ░
 3  │   █         █         █          ░
    │   █         █         █          ░
    │   █         █         █          ░
 0  └───▀─────────▀─────────▀──────────▀─────────────
      Socks     Jeans     Shirts   USB Drives

Media objects are supported, like images and video:

A room in an old French castle (2024)

They extend to the width of the page, and add appropriate padding in the bottom to maintain the monospace grid.

Discussion

That’s it for now. I’ve very much enjoyed making this, pushing my CSS chops and having a lot of fun with the design. If you like it or even decide to use it, please let me know.

The full source code is here: github.com/owickstrom/the-monospace-web

Finally, a massive shout-out to U.S. Graphics Company for all the inspiration.

联系我们 contact @ memedata.com