Author mentions this took a long time to arrive at.<p>I recommend "Web Design in 4 Minutes" from the CSS guru behind Bulma:<p><a href="https://jgthms.com/web-design-in-4-minutes/" rel="nofollow">https://jgthms.com/web-design-in-4-minutes/</a>
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.<p>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]<p>I was expecting something akin to normalize.css[1] which normalize the default styles of your page[2].<p>There are multiple very lightweight CSS "frameworks" that you should carry around instead of the snippet shown here. We are talking ~5KB. See <a href="https://github.com/troxler/awesome-css-frameworks#very-light" rel="nofollow">https://github.com/troxler/awesome-css-frameworks#very-light</a> for a great list.<p>[0] <a href="https://jrl.ninja/etc/post.css" rel="nofollow">https://jrl.ninja/etc/post.css</a><p>[1] <a href="http://nicolasgallagher.com/about-normalize-css/" rel="nofollow">http://nicolasgallagher.com/about-normalize-css/</a><p>[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.
It's 61 bytes because you're using two spaces instead of tabs! :^)<p>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.
The author actually loads 10x that much CSS (546 bytes) into the example page! [1]<p>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]<p>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]<p>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.<p>I left the unmentioned line-height in because it's a good default. It adds a little basic spacing between wrapping lines of text.<p>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.<p>[1]: <a href="https://jrl.ninja/etc/post.css" rel="nofollow">https://jrl.ninja/etc/post.css</a><p>[2]: <a href="https://jsfiddle.net/gb0ojdsL/8/" rel="nofollow">https://jsfiddle.net/gb0ojdsL/8/</a><p>[3]: <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag" rel="nofollow">https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/View...</a><p>[4]: <a href="https://css-tricks.com/what-you-should-know-about-collapsing-margins/" rel="nofollow">https://css-tricks.com/what-you-should-know-about-collapsing...</a>
> main {<p>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.
Is it just me, then, that hates the "narrow strip of text down the middle of my large monitor" school of web design?<p>I don't understand why I'm being forced to scroll when there's all this blank space to the sides.<p>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.<p>What's the reasoning behind this?
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.<p>It feels very easy to read. So much clutter has been taken away.<p>There’s nothing pulling at the edges of your attention and ruining the experience. I quite like it.
Still wastes 60% of my display's width.<p>Sorry, if you are into minimalist design I keep getting back there, with 58 bytes less of CSS: <a href="https://motherfuckingwebsite.com/" rel="nofollow">https://motherfuckingwebsite.com/</a>
I notice that the author doesn't use capitals either and I'm not sure if visually I like that or not. It makes it feel more casual which is nice, but I think it does get harder to parse the sentences.
I find it interesting that this snippet is used:<p>::selection {
background-color: #ff0;
}<p>Because when f.lux raises the color temperature for the evening it makes it so I can barely see if anything is selected while the normal color works perfectly no matter the temperature I set. At first, I thought it was one of those JS scripts that prevent selection.
My favorite resource about minimalist CSS : <a href="http://bettermotherfuckingwebsite.com/" rel="nofollow">http://bettermotherfuckingwebsite.com/</a><p>And at least it uses its own recommendations, whereas the OP isn't (it ships way more CSS than the mere 58bytes it talks about)
> it took me a surprising number of iterations to arrive at this point. perhaps that speaks to the fact that i know nothing about "modern" web development, or [..] just how hard it is to keep it simple in a world of complication.<p>It's the latter. Being both simple and good is not easy.
I recognize some of those scrots. Funny to see another /g/ent with a minimalist setup and website.<p>I have about twice the amount of CSS, but most of it was to match my personal setup of colors/fonts: <a href="https://nadyanay.me/assets/css/style.css" rel="nofollow">https://nadyanay.me/assets/css/style.css</a><p>361 characters (yours) vs 615 characters (mine)<p>Remove the font family and .fav classes and some of the unnecessary border overrides and mine comes out to a more equivalent 319 characters, while still retaining the spacing and color scheme.
Looks great even without CSS. The only exception is a very wide viewport.<p>1024x768: <a href="https://i.imgur.com/NEAenbY.png" rel="nofollow">https://i.imgur.com/NEAenbY.png</a><p>320x568: <a href="https://i.imgur.com/TdVjnKR.png" rel="nofollow">https://i.imgur.com/TdVjnKR.png</a><p>3480x1600: <a href="https://i.imgur.com/MfhxmRD.png" rel="nofollow">https://i.imgur.com/MfhxmRD.png</a>
Please don't do this with max-width it makes printing a huge mess, I regularly have to edit max-width on sites that set it so I don't have to print double or triple the number of pages, at least set max-width to be a relative unit for print.
That text area is way too narrow. It inhibits scanning to be unable to see very much of the text at once, because it forces you to scroll see more than about a paragraph at a time.<p>Readability isn't the concern. Show me a book with margins that gigantic.
Cool! For my personal taste a little bit too much padding for my Galaxy S9 though. 1.25rem or 1.5rem would be sufficient and gives another 1-2 characters per line. But that's mostly personal taste.
I would suggest you to always put a `color` when you define a `background-*`.
Now that website can support darkmode,
it would be a shame to see a white text on this yellowish background...
I'm definitely going to steal your website design (please don't sue me). But I don't like sans-serif fonts. What serif fonts do you recommend to use instead?
I’m an outsider to this world so please forgive the basic question: what is “main”?<p>Does its use depend on any particular markup in the HTML?<p>And how far back does it go as a CSS feature?
This is definitely better than nothing.<p>I personally prefer a bit more so that It looks good on my old crappy phone with far fewer than 600px wide. water.css is great.
> it appears that the default font size for most browsers is 16px, so 38rem is 608px<p>What does px mean in CSS? I thought it was pixels but clearly not...
Three more:<p><pre><code> body { font-size: medium; }
main, article, content { font-size: 1rem;}
p, li, dd, dt, blockquote { font-size: 1em; }
</code></pre>
Give the user their default font size, <i>not</i> some px-defined kludge.<p>Em vs rem: <a href="https://news.ycombinator.com/item?id=19608806" rel="nofollow">https://news.ycombinator.com/item?id=19608806</a>
There's more CSS on the page than that though.<p>And it <i>doesn't</i> look great everywhere. At 375px-wide the line-length of the text is ~35 characters, optimal would be 50--70.
> that speaks to the fact that i know nothing about "modern" web development<p>I thoroughly agree with his statement and just wanted to post this to help emphasize the fact.
> max-width: 38rem<p>> supporting 600px displays at a minimum seems reasonable.<p>Max-width is just that: maximum width. That CSS is not "supporting 600px displays at a minimum".
Another good resource for this "minimal" approach is:<p><a href="https://motherfuckingwebsite.com/" rel="nofollow">https://motherfuckingwebsite.com/</a><p>.. and it's followup:<p><a href="http://bettermotherfuckingwebsite.com/" rel="nofollow">http://bettermotherfuckingwebsite.com/</a><p>(Both are SFW sites except for the use of expletives in the URL/title).