The W3C recently announced a Cascading Style Sheets (CSS) snapshot – a document that "collects together into one definition all the specs that together form the current state of Cascading Style Sheets (CSS) as of 2015. The primary audience is CSS implementers, not CSS authors, as this definition includes modules by specification stability, not Web browser adoption rate." This motivated me to consider the relevance of CSS in today’s modern web developer community, and how best to implement today.
Because so much has changed over the years, I thought it would be appropriate to do a developer based ‘snapshot’ of where CSS is now, and how to embrace the future. My personal experience was not enough to satisfy an answer, so I did much research and interviewed industry experts on their point of view. With all the data I acquired, I knew I had enough findings to support writing a book! I decided writing series of online articles on CSS would be much quicker to market, so I am proud to introduce this first post of the Mastering CSS Series.
Is CSS relevant today?
For many web developers, the notion of questioning the relevance of CSS may seem odd. However new trends in web development have put in question the use of CSS. I strongly consider reading the article by Louis Lazaris, who presents the case that CSS is alive and well. Although most of his article provides insight into why CSS is still quite alive, he also mentioned the popularity of React, which uses inline styling via JavaScript. He also references an article regarding the debate around "do we even need CSS anymore?" which does a good job explaining some of the pain points developers have faced when implementing CSS. I am referencing these articles because they provide context for the challenges CSS developers face, and why some have considered other alternatives. So does that mean CSS is trending down?
As the opening words of this article clearly show, there is momentum in the field of CSS. The major browsers out there are still working hard to implement CSS features, and the passionate developer community is working hard to continue making great websites with CSS. Think of the innumerable blogging sties using WordPress which of course uses CSS to complement theming. With a strong foundation and active community, CSS is very relevant today.
What about the valid arguments against CSS? While I will not be addressing them here, I am happy to see the ‘uproar’ and some turning toward alternatives. Why? Because it is healthy for the community to challenge how things are done so that there is opportunity for improvement. It is my humble opinion that the CSS of the future will be molded by the very complaints against it today.
Simple CSS truths
In our modern world, I find it is good to pause and question why we are doing what we do. In the spirit of questioning my personal continued use of CSS, I wanted to come up with evidence of why I should still care to do so. Below is a list of statements I concluded (with the help of others) that add weight to why CSS continues to be my dominate choice for styling with web technologies:
CSS allows for separation of concerns. CSS is a complementary language to HTML, enabling style definitions to be maintained separately from the markup. Cleaner markup is easier to read and maintain, and is typically easier to crawl by search.
CSS is fast. It is fast in many ways. Faster to make style changes, faster for HTML pages to load that aren’t riddled with duplicate inline styles, and typically faster to process than JavaScript in cases like transitions and animations.
CSS is responsive. CSS enables the best viewing of content based on viewing dimensions or how it should be rendered if printed, to name just a couple of examples.
CSS has a captive audience. There is no shortage of books, videos, articles, and websites centering on CSS. And there is a growing list of libraries/tools/frameworks dedicated to make CSS implementation easier and more efficient.
CSS is everywhere. Modern browsers embrace CSS, and a list of features supported by each is maintained at sites such as CanIUse.com (see comment below). CSS is also used to style mobile apps found across multiple platforms when packaged using services like ManifoldJS or Cordova.
Regarding the status of CSS across browsers, a more accurate gauge for determining what features are currently supported or in development can be obtained by consulting directly with each specific vendor. For example, check out the platform status section at dev.modern.ie for the CSS roadmap regarding Microsoft Edge
Using CSS today
There are multiple ways to implement CSS today. There is no single method that is perfect for all scenarios, since different projects will have varying needs and constraints. Questions that would contribute toward determining an approach include: What features of CSS does the project require? What browsers/platforms does my project need to support? How many developers will be contributing to project, and what are their skill levels? Are the fastest response times a high priority?
After considering the questions above, it is now time to look at what approaches are out there. The combination of possibilities is high, so I will break it down to these two general terms:
Manual implementation and maintenance of CSS. Simply put, the developer is responsible for all aspects of CSS.
CSS with the help of extensions/frameworks. Developer depends on an extension or framework to help write efficient CSS and/or to publish a minified file. The types of extensions/frameworks are varied, and many of them have dependencies on one or more of the others.
While the second approach is clearly trending in adoption, it doesn’t mean it is always the answer. For example, a small intranet site with a predictable audience in terms of browsers/devices might appear over-engineered to implement multiple CSS frameworks – especially if the site had a small number of pages. Would minifying files be critical in such a scenario? Would it take more time for developers to set up the frameworks and learn them than to just write the site? A manual implementation of a single CSS page may be all that is needed.
The reality is many sites will be a lesser or stronger degree of the second approach. For example, a developer savvy with CSS may have excellent skills but relies on tooling for minifying files. Another example is using a full framework like Bootstrap, and purchasing themes to quickly get a site up and running. Another example may be the use of W3.CSS for simple responsive styling. To the degree any dependency will help (not hurt) the overall project, it should be strongly considered for use.
Summary
CSS has a history, an active presence, and a continued future in web development. While there are challenges to implementing CSS, there are also many reasons why it continued to be the reigning technology for styling the web. This article focused on the role of CSS in our modern world. Upcoming articles in the Mastering CSS Series will cover best practices, top tips, and a deeper look into extensions and frameworks!
More hands-on with Web Development
This article is part of the web development series from Microsoft tech evangelists and engineers on practical JavaScript learning, open source projects, and interoperability best practices including Microsoft Edge browser and the new EdgeHTML rendering engine.
We encourage you to test across browsers and devices including Microsoft Edge – the default browser for Windows 10 – with free tools on dev.microsoftedge.com:
More in-depth learning from our engineers and evangelists:
Our community open source projects:
More free tools and back-end web dev stuff: