Readit News logoReadit News
mushufasa · 7 years ago
Author mentions this took a long time to arrive at.

I recommend "Web Design in 4 Minutes" from the CSS guru behind Bulma:

https://jgthms.com/web-design-in-4-minutes/

ainar-g · 7 years ago
Disclaimer: I am not a graphic designer. I am merely a programmer with an interest in well-crafted, understandable, and readable text. So, read this as an outsider rant rather than an informed opinion.

  Black text on a white background can be harsh on the eyes.
I have to disagree about the problem here. Black text has been fine since the first printing press. And if you do want to make a page less in-your-face with regards to contrast, then it would be much better to dim the background. After all, the paper we read is mostly this grey-ish, yellow-ish colour.

  The accent color can be complemented with more subtle shades, to be used on
  borders, backgrounds, or even the body text.
The colours they've used in the syntax highlighting just made everything a confetti explosion. I am not against syntax highlighting, but it shouldn't be this colourful, unless you give every identifier a computable colour to make misprints more noticeable.

  Since text is the main content of a webpage, using a custom font gives the
  page even more noticeable identity.
Not a big fan of @font-face. Another host to visit. Another asset to download. My fonts are fine. If I have the font you like, then great! If I don't, please make it look reasonable with system defaults.

  Let's enhance our header with a nice background image from Unsplash.
Let's not. Massive headers are nothing but a waste of space.

Again, this is a rant. I am just very tired of “designers” doing “pretty” stuff instead of solving a problem. And that problem is an aesthetically pleasing, not-eye-hurting, reasonably dense text.

natermer · 7 years ago
You may be wrong or may be right, but all I can say that after looking at the demo the text became significantly more difficult to read after the CSS coloring was applied to it.

Unlike you I do have a lot of experience in graphical stuff, specifically finer art. And I do understand more then the average person on color theory.

The thing to keep in mind with all of this is that black isn't black. White isn't white. White and black have tints. You can have cool whites, and cool blacks. You can have warm whites and warm blacks. What you will never have is white whites and black blacks.

Lowering color contrast is a trick that is used in art to make things seem far away or behind the more colorful pieces of art. Part of that is because reduced contrast makes details harder to see, which corresponds in people's minds to distance because distance makes details harder to see. (other factors are going to be things like that atmosphere has it's own colors and these begin to compete and wash out colors at a distance).

High contrast makes it easier to read text. But it needs to be the right type of high contrast.

If you try to pick the blackest black you can and the brightest white then that means you are letting the viewer's monitor dictate what the tinting will be. And mixing colors incorrectly results in a shimmering or 'vibrating' effect in the eyes. So depending on the user's settings it may be easy to read or it could be irritating. Which as a designer isn't going to be something you want.

I have a idea that the author of the "Web Design in 4 Minutes" is extremely good at writing CSS and not so hot at web design. Which are two different things.

mpolichette · 7 years ago
I don't want to sideline a thread on a single point, but I do think there is a difference between the unlit black ink on white paper of years passed, and the modern backlit monitor shining like a bright a flash light in your eyes.

I don't think "dark theme" is always the right answer, but I think with a new medium, a new basic is worth considering.

jdmichal · 7 years ago
I'm with you on fonts. So much so that my first Firefox customization on any computer is locking down the font. Every webpage gets the same font, because I like that font and find it readable and I don't see why I should have to look at anything else.

Content :: Fonts and Colors :: Advanced :: Allow pages to choose their own fonts

zamalek · 7 years ago
> Black text has been fine since the first printing press

Keep in mind that paper is not an emissive surface, like an LCD panel is. Black-on-white is fine for e.g. e-ink displays or calibrated brightness (~15-30% on most displays, which is not the default).

Phrodo_00 · 7 years ago
> Not a big fan of @font-face. Another host to visit.

While it is an additional HTTP request, it's not necessarily another host. You can perfectly host fonts in your own site

lifthrasiir · 7 years ago
> Not a big fan of @font-face. Another host to visit. Another asset to download. My fonts are fine. If I have the font you like, then great! If I don't, please make it look reasonable with system defaults.

I will reiterate my past comment that it is inevitable for many non-English scripts.

https://news.ycombinator.com/item?id=19569571

chipotle_coyote · 7 years ago
You don't need to visit another host just because you're using @font-face! The fonts can be stored locally. If you visit my home page, coyotetracks.org, it loads five fonts (bold and italic Concourse, and regular, bold, and italic Equity) for an extra 82.18K -- which, unless you're taking steps to prevent it, your browser is going to cache from that point on. (If you visit another page, you'll probably get the regular version of Concourse, too, for an extra 11.45K.)

I just don't get the HN hatred for downloadable fonts in and of themselves. If you're talking about an extra megabyte or two of JavaScript and unoptimized fonts, okay, but that's a problem of implementation. Why this cranky "it's just the text that matters, stop trying to make it look pretty" mindset?

mixmastamyk · 7 years ago
Indeed #555 for text is ridiculous.
dalore · 7 years ago
> I have to disagree about the problem here. Black text has been fine since the first printing press. And if you do want to make a page less in-your-face with regards to contrast, then it would be much better to dim the background. After all, the paper we read is mostly this grey-ish, yellow-ish colour.

I have to disagree with your disagreement. Paper and screens are completely different. Paper is passive whilst screen emit light.

So it's much better to have screens have a dark background and emit the text, so our eyes aren't as strained receiving so much light. It's far easier to see a headlight in the dark for example then during the day.

Whilst for paper, the only reason it's black on white was that we had dark ink which went on light materials. It's a lot harder to find light ink that goes on dark material.

sixothree · 7 years ago
> Black text on a white background can be harsh on the eyes.

I did not take this to mean a non-inverted color scheme is hard. I understood this as pure black on pure white is harsh.

Notice he uses #566b78 as the body color instead of #000000.

colechristensen · 7 years ago
>I am just very tired of “designers” doing “pretty” stuff instead of solving a problem

Rewording, I am tired of "pretty" being an add-on or, worse, the entire product.

philliphaydon · 7 years ago
> Black text has been fine since the first printing press.

Isn’t this due to cost?

bbx · 7 years ago
Haha, thanks for sharing this. It's been a while since I wrote that!

You're right to mention it because in the 2nd step "Centering", I use the same technique: adding a max-width and using auto margins for the left and right sides.

On a side note, this reminds of the "Doing it more vs. doing it better" thread that was here on HN yesterday [1], and how the JS code of "Web Design in 4 minutes" is quite bad… I just wrote those 50 lines directly in the HTML, at the end of the page, and tested it manually a few times. As a result, it is tightly coupled to the markup, and still has lots of bugs. But I imagine that if I had focused on writing "beautiful" code instead, I probably wouldn't have shipped the project in the first place.

[1]: https://news.ycombinator.com/item?id=19600440

RobertKerans · 7 years ago
Bloody hell, I've been trying to find for this for ages. I knew there was _something_ I'd read that gave a great step by step overview that I knew at the time would be helpful whilst teach beginners, but I couldn't remember what it was called or who wrote it, and it's nearly impossible to search for when the details of it were sketchy ("step by step web design tutorial"??). Just want to say thank you for writing this (and thank you to OP for posting the link)
mushufasa · 7 years ago
Thanks for shipping it!

Last year I started to build a web app without knowing how to code -- I started not knowing the difference between CSS and JS. You can imagine how confusing the current ecosystem is to beginners. (My co-founder and I taught ourselves to be the technical co-founders). Your tutorial really helped, and I'm using Bulma :).

JoshuaRLi · 7 years ago
Oh wow, great read... I wish I had seen that earlier. Thanks for sharing! To elaborate, the rabbit hole I remember going down was something like googling "how to center css", then after being confused by a number of horrible incantations, arrived at flexbox then CSS grid, which was slightly less confusing, and then I took some time to really study the basics/fundamentals.

It also doesn't help that so many websites, even personal sites/portfolios these days, have so much markup goop and cruft that makes it quite hard to learn by example :(

victorvation · 7 years ago
Although Jeremy Thomas' design might be more complete, I do like the minimalism of your approach - a few lines that can be dropped into a page to quickly take it from unreadable to a pleasant experience. The only things I'd add are font-family: "San Francisco", "Helvetica", sans-serif;, and perhaps line-height: 1.5.
craftyguy · 7 years ago
> I recommend "Web Design in 4 Minutes" from the CSS guru behind Bulma

There's irony in the fact that this website is completely non-functional and no content is displayed when JS is disabled. You'd think a CSS guru would not rely on JS to display text.

buzzerbetrayed · 7 years ago
> You'd think a CSS guru would not rely on JS to display text

The reason people love this website is because the content changes as you learn each concept. The way you "change" content in web development without reloading is through javascript. It is about as close to a perfect use case as you can find.

There is nothing ironic about that.

vkaku · 7 years ago
I'm sure he could do that by navigating to a new page every time. But the tutorial is about styling one step at a time without getting distracted, and I think that is solid teaching.
clydethefrog · 7 years ago
If you search for "motherf--ing website" you also have many examples of a very simple but readable website. (I hate the edgy language though.)

https://news.ycombinator.com/item?id=6791297

reificator · 7 years ago
> (I hate the edgy language though.)

I understand where you're coming from, but I do think it serves an important purpose here.

The language is chosen to underscore the message and ensure virality. The goal was to get the point in front of as many people as possible, and it did that quite well IMO.

I'm not sure that message could have spread as far and wide as it did without that language. Perhaps if FAANG pushed it...

creinhardt · 7 years ago
optymizer · 7 years ago
Once the text goes to gray, it is objectively harder to read.
tarruda · 7 years ago
This is the best CSS/design tutorial I've seen, thank you for sharing.
boomlinde · 7 years ago
That is an interesting format. It's encouraging to see small, incremental changes to the style sheet result in so vast improvements in legibility.
kbenson · 7 years ago
I agree, but I found the first half much more useful (so far) than the last half. The second half was honestly a little overwhelming it what it felt like it was assuming about my capabilities. Less of "this small change or some slight variation will help a lot" and more "use your design experience to choose something visually pleasing here", which honestly, the lack of such experience is why I was reading such a guide.
Narishma · 7 years ago
For me it started being less legible after the font change to Arial and kept going downhill from there.
avip · 7 years ago
This is a wonderful tutorial. I wish back worked though.
justusthane · 7 years ago
Agreed. I keep wanting to compare the differences between two steps.
sfusato · 7 years ago
Thanks for sharing this.

* I clicked your link * closed the HN tab * was completely blown away by the article * "Reopen closed tab" and up-voted your comment

Myrmornis · 7 years ago
That's really cool and will help me a lot with CSS I think. However, as others have mentioned, the change from black to a gray text color #555 makes things slightly worse and would be better if it were a darker gray. It does make one trust the article less.
jeltz · 7 years ago
The text just becomes harder and harder to read the more it progresses.
ar_lan · 7 years ago
Wow, that's nearly definition of a great tutorial.
admax88q · 7 years ago
As the contrast keeps getting lower that page keeps getting harder to read. We don't all have super bright macbooks turned to full brightness.
To1ne · 7 years ago
> What is the first thing you need to work on?

Your hyperlinks need to work without Javascript.

ngold · 7 years ago
Looks promising for a Web Development quicky.
Raphmedia · 7 years ago
It's a cool little snippet but it's nothing more than three run-of-the-mill CSS declarations. The maximum width is specified, a small padding is applied and the margins around the element are set to automatic so it centers itself horizontally.

All the other styles applied on this pages are not part of the snippet. The weight of the titles, the spacing under the paragraphs, etc., are all specified on the page's CSS file but not described in the blogpost itself. [0]

I was expecting something akin to normalize.css[1] which normalize the default styles of your page[2].

There are multiple very lightweight CSS "frameworks" that you should carry around instead of the snippet shown here. We are talking ~5KB. See https://github.com/troxler/awesome-css-frameworks#very-light for a great list.

[0] https://jrl.ninja/etc/post.css

[1] http://nicolasgallagher.com/about-normalize-css/

[2] Normalize CSS aims to make built-in browser styling consistent across browsers. Elements like H1-6 will appear bold, larger et cetera in a consistent way across browsers. You're then supposed to add only the difference in decoration your design needs.

discreditable · 7 years ago
It's 61 bytes because you're using two spaces instead of tabs! :^)

You can shave off 2 more bytes by using em instead of rem. In your use case they are functionally the same. Rem is em relative to the root element. Your <main> pretty much is the root element.

wolfgang42 · 7 years ago
When fully minified, it's actually 47 bytes: main{max-width:38rem;padding:2rem;margin:auto}

But I think the original is still well into the land of diminishing returns.

discreditable · 7 years ago
Agreed, but OP isn't serving minified content.

I brought up rem vs em because the difference is subtle and if you're byte shaving it's "free" bytes.

PopeDotNinja · 7 years ago
46 bytes if you take out the new line :)
JoshuaRLi · 7 years ago
I definitely considered this! But rem feels more predictable and straightforward. I have seen debates on em vs. rem, and there is certainly value with em in websites that have lots of nested and/or discrete responsive components, but for a very simple site, I quite like rem.
dredmorbius · 7 years ago
Ue rem when your reference is the base page. Use m when the refrerence. is surrounding text.

As examples, I size page elements in rem, but text elements (usally), in em.

My main, content, article, header, footer, and aside should all generally reference page, and are in rem.

Main body text width, headings (h1 ... h6), super- and sub-scripts, code and pre blocks (often jarringly sized by default) reference the containing unit and should be in em units. Also, generally, figure and table captions, table text, etc.

I prefer to give figure or sub-element (tables, callouts, note boxes, etc.) margins and paddings in em as well.

shawnz · 7 years ago
In my opinion em would be more predictable. With the current configuration, users of this package would only be able to adjust the font size by setting font-size on the html element, but not on the body element or any container elements of the main element, or even the main element itself. That is pretty confusing to me, I think it is a pretty typical expectation that making the font size of a container bigger or smaller should always make everything inside proportionately bigger or smaller.
discreditable · 7 years ago
Are you sure you don't have the meanings reversed? REM is the one that ignores nesting. EM doesn't, so on a simple site it's easier to use correctly.
janpot · 7 years ago
Remove all spacing to save even more.
rident · 7 years ago
The author actually loads 10x that much CSS (546 bytes) into the example page! [1]

Granted that is still not much but here I've augmented the 546 byte example to render nearly the same results with only 155 bytes. [2]

I've removed rem units as it's easier for all to understand without them. Pixel units scale just fine across the browsers available these days so there's no need for the mental hurdles and explained calculations. I've left them in the source HTML all the same for the sake of testing. The real feature making sites look good across a ever widening array of pixel densities today is this meta tag that was also used in the example HTML: <meta name="viewport" content="width=device-width"> [3]

Setting a font-family generically on the body tag gives the shortest path to consistent, doesn't-look-like-times-new-roman, font styling possible.

I left the unmentioned line-height in because it's a good default. It adds a little basic spacing between wrapping lines of text.

Styling elements that are children of the article to only have bottom margins gives consistent spacing to all content, and since top margins collapse [4] we can avoid dealing with them all together.

[1]: https://jrl.ninja/etc/post.css

[2]: https://jsfiddle.net/gb0ojdsL/8/

[3]: https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/View...

[4]: https://css-tricks.com/what-you-should-know-about-collapsing...

JoshuaRLi · 7 years ago
Haha yes, I mean 58 bytes for layout, not layout + styling.

Anyways, what you've written here is good, and definitely encompasses some things I thought about. Two notes for you:

1. I explicitly preferred Arial and Helvetica over the generic sans-serif is because I found some other popular web safe fonts didn't look nearly as good, for example, Open Sans, mainly due to the large x-height.

2. I don't think rem incurs much cognitive overhead over px, and the main reason is that it scales with the user-adjustable font size. Try changing your browser's font size from 16 to say, 20. You'll notice that with px max-width, # chars per line will decrease a lot, affecting readability. in contrast, rem max-width will scale nicely.

theandrewbailey · 7 years ago
> main {

Why not target <body> instead? <main> should not have content that is shown on other pages, like headers, footers, and sidebars, but it makes sense to have this CSS affect those areas.

jhardy54 · 7 years ago
Yep, I think the priorities should be <html> and <body>. Here's mine, which centers the content both horizontally and vertically via flexbox:

    html {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 100%;
    }

    @media screen {
      body {
        max-width: 40rem;
        margin: 1rem;
      }
    }
It's not perfect, but it works well for simple websites (e.g. https://colorclock.hashbase.io/).

cimmanom · 7 years ago
IIRC, the way browsers interpret margins and widths on the <body> element isn't consistent; and they may not support overriding block properties on the <html> element at all. Or maybe they do now, but that certainly wasn't cross-browser-friendly until very recently.
albedoa · 7 years ago
Also, flexbox allows a child element to center itself using `margin: auto;`: https://codepen.io/anon/pen/gyLGwW
sucrose · 7 years ago
I cannot access your website: ERR_SSL_PROTOCOL_ERROR
JoshuaRLi · 7 years ago
Oooooh. Good point. Currently, I have header (which has the post title, and date) nested in article, nested in main. Nesting the header inside the article makes sense to me, but you're (and other people on the internet/s.o., as I am now seeing) suggesting that header should be outside main.

I agree, and making those changes would mean I can switch from main to body in my css. The main complaint I have is then article and main seems redundant. What are your suggestions? Semantic HTML5 is hard :(

brlewis · 7 years ago
An earlier screen-reader discussion suggested that <main> is of interest to screen-reader users. I presume that's because it generally doesn't repeat navigation that exists on every page.

https://news.ycombinator.com/item?id=18758847

theandrewbailey · 7 years ago
From my understanding, a document can have a header, footer, and/or multiple articles[0], with each article potentially having a header/footer specific to the article[1]. Presumably, the article(s) should be contained in a <main>.

[0] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ar...

[1] https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Usin...

Eiriksmal · 7 years ago
The semantics are only suggestions, not hard and fast rules.

If you aren't adding top nav sections or site-wide footers, your current approach is fine.

If you do want to experiment with those, you'll find the (correctly-constrained!) body content looks funny with copyright footers floating in space somewhere to the left or right of the main text.

marcus_holmes · 7 years ago
Is it just me, then, that hates the "narrow strip of text down the middle of my large monitor" school of web design?

I don't understand why I'm being forced to scroll when there's all this blank space to the sides.

Even on my laptop, this looks strange to me, a huge wide expanse of nothing, and this little strip of text down the middle of the page.

What's the reasoning behind this?

twhb · 7 years ago
Lines should be between 50 and 70 characters for optimal readability. Longer lines take longer to read because you increase the time you spend seeking the beginning of the next line. You can increase line height to compensate, but the seek time improvement is small and the information density decrease is large, and it looks pretty terrible. Columns would be a great solution, but HTML/CSS’s tooling for it has a lot of integration and polish issues, so doing it in a way that’s actually better than the strip is a lot of work.

Arguably, though, a website that’s surrendered to the strip should make some compromise between line length readability and reducing scrolling.

roystbeef · 7 years ago
It's to help readability for larger blocks of text, so it's easier to find the next line when the text wraps
0815test · 7 years ago
> What's the reasoning behind this?

Lack of multi-column text support on the Web. Optimal readability is around 64 characters per line - more than that hurts quite a bit, especially for long-form text where accurate scanning is more important.

Macha · 7 years ago
https://caniuse.com/#feat=multicolumn

Even IE10, mobile safari, and the gingerbread android browser support it

wa1987 · 7 years ago
Constrained line lengths increase readability:

https://practicaltypography.com/line-length.html

Zak · 7 years ago
A reason is that scanning horizontally with your eyes while reading a long text increases the chance you'll lose your place.
olav · 7 years ago
What became of text columns https://caniuse.com/#feat=multicolumn to enhance readability and still use all that space? Is anybody using them?
DantesKite · 7 years ago
I think because so many of the people here are programmers, there will be some incentive to talk about the code, but the design is lovely.

It feels very easy to read. So much clutter has been taken away.

There’s nothing pulling at the edges of your attention and ruining the experience. I quite like it.

Eiriksmal · 7 years ago
After seeing Gwern's website[0], I immediately knew what design I wanted for my personal site [1]. Tufte's CSS package is much heavier than these three rules, but it achieves the same result: Content designed to maximize readability by removing distracting elements and respecting known typography rules.

Because I write with an overly-large number of asides, I fell in love with the Tufte-styled side/margin notes. The resulting text is much easier to read, since I'm not littering the paragraphs with em-dashes and lengthy parentheticals.

I hope more people rebel against the Medium-looking websites with massive images and huge blocknotes in 30px fonts that may or may not just be a line from the next paragraph or an important point to keep in mind when reading the next paragraph.

#longformrebellion #endthelisticle

[0] https://www.gwern.net/About

[1] https://lawler.io

JoshuaRLi · 7 years ago
Your website is wonderful, I encourage you to share it more! I did some extensive preliminary research looking around at personal sites posted to HN and other places, and am now surprised I hadn't yet stumbled upon yours until now.
detritus · 7 years ago
Lovely, but if you're making a big deal about quotes and pull-aways in your format, might I encourage you to use proper quotation marks — eg. “The” vs. "The"?
reindeereffect · 7 years ago
Bonus points for looking sharp when I have JavaScript disabled.
sigspec · 7 years ago
Gorgeous
JoshuaRLi · 7 years ago
Thank you! Before making this I visited a bunch of personal sites / blogs that had been posted here, and surprisingly very few of them were similar in this regard. I may post about the websites that gave me inspiration in the future. (You may like https://legiblenews.com)
mftrhu · 7 years ago
It looks like LegibleNews stopped updating back in January. What a pity, I really liked the concept.