Old CSS, New CSS (2020)
eev.ee
eev.ee
<H1><FONT COLOR=red>...</FONT></H1>
to (Tailwind CSS) <h1 class="text-red-500">...</h1>
I totally acknowledge the accomplishments that the Web standards and their implementations have made since the early days.On the other hand, while I am no Tailwind proponent, for many applications "worse is good" and Tailwind is a bridge to the straightforward beginnings of the web design.
What, so that it actually means blue and 400? That doesn't sound good for maintainability.
If “red-500” is your company color, it should be redefined in your config as “company” and write “text-company-500”. That way, if your company branding changes, you don’t have to “hack” red-500 to be blue-400; you just change the definition of “company”.
They’re basically CSS variables.
Now, I can define my flex boxes, vertical flex boxes in a snap. Apply one of several common padding and margins to an element in a one-liner. Throw "vertical-center" onto an element to make it align-items:center. 80% of the layout I need to do can be composed in one shot without new css. Then I can make fine-tune adjustments using variables.
I don't remember what the exact text of any of the 4 box shadows I use. I know I apply two shadows (one shallow dark one and one further light one), but I couldn't tell you what the opacity is on either. I don't need to. I either apply it in the class or @extend .shadow-1;
module.exports = {}
That alone gives you all the Tailwind defaults. But it’s customizable to infinity. tailwindcss.com’s documentation on individual classes is extensive on customization.But if you insist: https://tailwindcss.com/docs/adding-custom-styles There you can see that the example config file there defines custom colors (which could be your company branding colors). They don't have to be named actual colors; I could use `"mygreen": "#8FB68F"` (random color I just generated) if I so desired. Then, during my website's build process (into static HTML), any usages of "text-mygreen-500", for example (colors are 100-900), will generate a CSS selector automagically.
function PrimaryHeader({children}){
return <h1 className="text-red-500">{children}</h1>
}
<PrimaryHeader>...</PrimaryHeader>
Thus, the 'separation of concerns' and many thousands of hours of developer toil ensued to both completely separate, yet still closely bind, style to markup by way of class names. There's no point to have a .PrimaryHeader class in a world of web components and atomic CSS (Tachyons, Tailwind, etc.)Even absent of an atomic CSS library, I still prefer inline CSS to making up arbitrary class names; my entire codebase can be JSX files, and every component is self encapsulating. I don't see this as 'worse' in any way.
Having recently dabbled with Tailwinds, I can't express how nice it is to have control over most styling within the JSX/HTML without having to jump between CSS class definitions. At just a glance from the class names I can figure out what everything is doing, and it feels much more productive.
I meant this phrase as in https://en.m.wikipedia.org/wiki/Worse_is_better.
Generally, we now have awesome levels of abstraction available for developers (and counting, for example see CSS Logical Properties). On the other hand, for simple solutions, less abstraction is the way to go. Luckily, there is still inline style for that.
hover:text-red-500
What about just at the medium breakpoint?
md:text-red-500
Only in dark mode?
dark:text-red-500
Tailwind is much more powerful than inline styles.
You could always have a global style variable in a framework like react, that in the end renders the "text-red-500" part. Changes are pretty easy too.
And, React has been the framework that brought this new paradigm to the forefront. The amalgamation of programming and UI design. As long as designers were at the helm of web-sites, we had tools like Adobe Dreamweaver. Once programmers were forced to do UI stuff, we had stuff like React / Vue / Angular on the horizon.
I now realize that HTML is a platform. No human should ever directly write an HTML file. We must build software that builds HTML.
I don't. It's taken all this time for CSS to catch up with table-based layouts, and it still doesn't really offer significant advantages if you're generating your markup from code (which we all are now). Video and audio tags are not noticeably better than HTML3-style embed; indeed in practice they're worse for the user (all that autoplaying video on news sites).
CSS exists to make it easier to DRY your hand-written HTML, which no-one does anymore. It's time to kill it.
On a related note, can anyone recommend a good CSS book or tutorial?
CSS supported table-based layouts since CSS 2.0 which is more than 20 years old at this point. See: https://www.w3.org/TR/2008/REC-CSS2-20080411/tables.html
If you are referring to grid, this is much more powerful than table, for example it decouples the visual order from the structural order.
IE only supported them from v8, so more like 10 years old in practice (a lot of CSS 2.x was "standardised" before it was implemented, and some of it turned out to not even be possible to implement). Though I was actually thinking of flexbox rather than table-layout, though I don't remember what (if any) the difference was.
But it was not CSS that had trouble catching up, it was a deliberate strategy by Microsoft because they considered the web a threat to its desktop dominance.
<!--[if lt IE 8]>
<table><tr>
<td width=640 valign=top>
<![endif]-->
There was a huge disconnect between what the standards documents supported and what browsers actually supported. There’s a reason they made that “smiley face” Acid2 test in the mid-2000s, because standards support was so bad back then: http://acid2.acidtests.org/ — https://en.wikipedia.org/wiki/Acid2I prefer vanilla HTML, CSS and minimal or no JS websites and my audience to a large part don't mind either and as long as I keep building to such niche audience then it's fine.
But if I try to compete in a market where the audience expect shiny layouts, fresh animations and don't mind waiting a minute for those to load; with a late 90s-esque website then I will certainly fail.
Those were the days. I kinda miss them. Everything was new and unexplored.
I don't think Peppermint Patty is disrespectful personally.
Peppermint Patty´s best frient, Marcie, tends to eccentrically call her "sir", which may be due to Marcie´s bad eyesight and Patty´s slightly tomboyish behaviours. Patty at first is hugely annoyed by that, but eventually starts to accept - or better, less obviously discourages - that behaviour.
Table is still good for making tables, that won't change layout based on screen or printer size. Very useful. For a spreadsheet type view, with strict columns and rows, regardless of screen, this might be a good option.
Grid is the best alternative where the grid must adapt to screen size, but there are still clear rows and columns in the layout.
Flex is more 1D than 2D, but can (easily) be coerced into 2D. It's great for things that should "flow" to fill the page.
So now instead of 1 (almost always bad) option, we have 3 distinct options, but it does take some experience to figure out when to use one, and when the other.
I recommend the guides at css-tricks for quick reference - I have them on speed dial.
> this company Netscape had been selling its Navigator browser (to businesses;
> it was free for personal use), and then Microsoft entered the market with its
> completely free Internet Explorer browser, and then Microsoft had the
> audacity to bundle IE with Windows. Can you imagine?
I believe the larger problem was that Microsoft offered companies and OEMs discounts on their Windows license fees if they agreed to stop purchasing any Netscape software, client and server, thereby collapsing Netscape's revenue from both ends.After they settled that case, they stopped offering discount, instead they just billed Windows copies by computer sold, independently of the OS.
Back in the days, you had to budget twice the time to make something work in two browsers that it took for one. This is not hyperbole. You'd gain a bit from doing something the second time, but lose just as much trying to make it work in more-or-less the same way.
Then, there are the complaints about Chrome: there is absolutely nothing wrong with the way Google manages Chrome, with the possible exception of what they are doing to adblocking. Their approach is to try to make the browser platform an equal among the walled gardens they fear, primarily iOS and, to a lesser degree these days, Facebook. None of the lessons of Internet Explorer apply, because the problem with IE was that it was using Windows-only extensions such as ActiveX.
I remeber seeing a great site around 2003 and spending night-time reading its code and trying to grab all the details on how they did it. Copy pasting its code to the Notepad and trying to replicate it in Microsoft FrontPage.
Next time I switch servers I won’t setup Apache so then it would need to be solved.
[1] It maybe gets updated once a year.
That’s literally how I got started with PHP 20 years ago, my host was dropping support for SSI’s but had support for PHP.
> The html is clean
Bye clean htmlUnless you're making a "classic" HTML page like an article, but then you wouldn't have trouble with CSS.
We worked with several accessibility experts when building Tailwind UI for example, and I am very confident in the semantics of all of that markup and how it performs in situations where that actually matters like when using assistive technology, because we tested it ourselves.
To add to this, screen readers for accessibility and search engine bots don't read CSS class names because they don't have standardised semantics (unlike HTML tags). Minifiers are allowed to mangle CSS class names because of this.
I think the problem here is it's common for people to confuse semantic HTML with semantic CSS class names. The latter are really to help your developers. If you're using utility classes though, you tend to use custom components to wrap + reuse styles versus using custom CSS classes so semantic class names aren't as important anymore. For others, this is explained well here:
https://tailwindcss.com/docs/utility-first
https://tailwindcss.com/docs/reusing-styles
I think the OP article is a good story on how we shouldn't cling on to current best practices. CSS was invented before complex single-page-applications were even a thing so it shouldn't be surprising at all if it turns out the old way doesn't scale well to our current needs.
The point of css was to fix this.
styled-system is a css-in-js tool that puts the css properties right on the element, just like this. A bunch of popular tools in the space do the same thing.
It‘s funny in an "everything that‘s old is new again" way.
With Tailwind, I work from the bottom up, with small composable classes, I notice common combinations and bundle them together in new classes. The end result is a lot better.
I never understood why CSS picked the obviously wrong way to define the box model. Who in their right mind would ever think that "width" would refer to the inner width of a box? I'm glad they finally added box-model: border-box, but the fact that there needed to be a switch at all is ridiculous.