{"id":17072498,"date":"2021-06-28T08:00:58","date_gmt":"2021-06-28T15:00:58","guid":{"rendered":"https:\/\/thenewstack.io\/?p=17072498"},"modified":"2022-05-06T07:00:52","modified_gmt":"2022-05-06T14:00:52","slug":"css-frameworks-in-vogue-but-dont-forget-style-fundamentals","status":"publish","type":"post","link":"https:\/\/thenewstack.io\/css-frameworks-in-vogue-but-dont-forget-style-fundamentals\/","title":{"rendered":"CSS Frameworks in Vogue, But Don’t Forget Style Fundamentals"},"content":{"rendered":"\n
\n\t\t\t\t Those of you old enough to remember the web in the late 1990s will recall the nightmare experiences of coding in CSS (cascading style sheets) during that time, largely because of browser incompatibilities. But we’ve come a long way since then. As CSS pioneer Eric Meyer<\/a> put it in a recent blog post<\/a>, the web of today, including CSS, has “vast capability and wide compatibility.” He added that the tipping point for CSS was in April 2017, “when four major Grid implementations shipped in as many weeks, and were very nearly 100% consistent with each other.”<\/p>\n CSS Grid Layout<\/a> is a responsive web design technique that is the modern equivalent of using HTML tables to control layout. Grid became available in Google Chrome in January 2017<\/a>, and although it’s still in draft status<\/a> at the World Wide Web Consortium<\/a> (W3C), is well on its way to becoming a web standard.<\/p>\n As Meyer noted, we have web standards advocates like the Web Standards Project<\/a> (WaSP) of the late 90s through till about 2013, and the W3C’s CSS Working Group<\/a> of today, to thank for the healthy state of CSS. But also the leading browsers of this era — Google Chrome, Firefox, Safari, and Microsoft Edge — are all mostly compatible with each other when it comes to CSS.<\/p>\n Another fascinating trend has been the continual rise of CSS frameworks like Bootstrap<\/a>, Materialize CSS<\/a> and Tailwind<\/a>. The first two are now nearly a decade old. Tailwind is the new kid on the block, having launched in November 2017. According to the 2020 State of CSS report,<\/a> an independent report run by Sacha Greif<\/a> and Raphaël Benitte<\/a>, Bootstrap is by far the most used CSS framework — 86% of survey respondents use it, compared to just 33% for the second most popular framework, Materialize CSS. But Tailwind was ranked highest in satisfaction (87%) and interest (62%). Notably, Bootstrap was near the bottom in both measures.<\/p>\n There are some key differences between Bootstrap and Tailwind (to pick the two most talked-about CSS frameworks). Grid layout is one of them. Tailwind supports CSS grid, but Bootstrap has an alternative system<\/a> of implementing a grid layout.<\/p>\n But the fundamental difference is that Tailwind has a “utility-first” approach, while Bootstrap is a CSS “toolkit” with predefined components, many of them JavaScript-powered. The idea is that it’s easy to quickly start up a new website or app with Bootstrap by choosing from its library of components. Tailwind is a lower-level abstraction, so it offers more flexibility in design.<\/p>\n Tailwind relies on utility classes, which Michelle Barker<\/a> has defined as<\/a> “CSS class names that serve one particular purpose, and are named as such.” She gives the example of the .bg-blue class, which defines the background color as blue. The Tailwind documentation lists a whole range of background color utilities<\/a> along with styles you can apply to them (hover, focus, etc.). In Tailwind, everything is done within the HTML file rather than in a separate CSS file. Tailwind’s tagline sums it up nicely: “Rapidly build modern websites without ever leaving your HTML.”<\/p>\n Although Tailwind is the trendy new CSS framework, it’s not without critics. As CSS book author Ahmad Shadeed noted<\/a>, “when the markup and styles are mixed [in HTML], things can get messy if you work on a complex multilingual, responsive, and themeable UI.”<\/p>\n Some influential people in the web standards community also don’t like utility classes because they lack semantics. As Jeffrey Zeldman wrote several years ago<\/a>, “Nonsemantic classnames that refer to visual styles will always be a bad idea.”<\/p>\n That’s the appeal of CSS frameworks, I guess.<\/p>\n — Eric Meyer of House Moderna (@meyerweb) June 16, 2020<\/a><\/p><\/blockquote>\nThe Rise of CSS Frameworks<\/h2>\n
CSS Framework Critics<\/h2>\n
\n