Before the introduction of CSS web pages were dull and lifeless. The internet as we know it simply wouldn’t be the same without CSS.
Let’s take a quick look at what CSS is and why CSS is necessary for web development.
What is CSS?
CSS is the shorthand for cascading style sheets which are used to style markup on web pages. It is most commonly used with HTML and is the driving force behind the appearance of all websites today.
Many believe CSS is a programming language in its own right and there is definitely debate to be had on that.
Before the introduction of CSS in 1996, websites just presented plain hypertext with images and links to other pages. There were no layouts as we know them today and everything was presented in a single column.
CSS brought numerous innovations to the web including the ability to:
- Specify fonts outside of browser defaults
- Change the color and size of text and links
- Modify background colors
- Change the positioning of page elements to allow them to float
Internet Explorer 3 was the first browser to read CSS but now all modern browsers do it out of the box. There have been several interactions to the CSS standard with the most recent being CSS3.
Is CSS necessary for web development?
CSS is incredibly necessary for web development, without it the modern web as we know it would not exist. More than 95% of websites use CSS for their styling and it’s the second most commonly used language in the development world. You simply can’t be a web developer without at least having a basic understanding of CSS.
Let’s explore some of the key reasons why CSS is so necessary for web development.
Learning Bootstrap instead of CSS may be a short-term time saver but you’ll run into countless issues down the line because you don’t know the basics.
2. Style and substance
Without CSS our websites would have no style or substance. We take the power of CSS for granted but your website’s entire layout depends on it. Long gone are the days of ugly single-column layouts that are a drain to look at.
While the content of your site certainly makes up a lot of the substance, without good styling users just won’t read it. Large blocks of unformatted text just aren’t appealing. Styling allows your content to be more impactful.
3. User Experience
The user experience of websites has improved dramatically over time. Old websites were an absolute chore to use and sometimes provided more problems than answers. User experience has become a flourishing field in its own right and for good reason. It is underpinned by what is achievable with CSS.
We are now able to more effectively organize and layout our web pages based on how users interact with them. Sites now transition in size depending on the device you are using. They provide different styles for various states and keep the user better informed as they navigate your site.
Try accessing a modern website with its CSS turned off. It’s a disaster.
4. Branding and engagement
Digital branding is now worth billions. Companies used to be hamstrung by physical print but now can be truly unique and innovative in their approach thanks to the web.
Websites and apps are an online continuation of a brand. Their appearances must align otherwise the experience is jarring. Brand colors, fonts, and images need to all successfully translate online for the optimum continuation of the brand.
CSS is necessary to make all this happen. Without it websites would have worse user engagement and life would be harder for brands to monetize their customer base online. CSS is not just essential for web development but has become a crutch that every serious brand has come to rely on.
One of the best things about CSS is its simplicity. You can get started using it with minimal setup and it’s portable to all your devices. From a developer’s perspective, it’s a dream to work with.
Once you get your head around specificity and understand how different styles interact you can achieve some awesome results.
The alternative to a stylesheet is writing all your styles inline. While this can be tempting it scales horribly and can make things incredibly complex. So without CSS projects would age poorly as maintaining them can be a nightmare.
6. No alternatives
Although libraries like React are slowly doing away with separate stylesheets in favor of inline styles, understanding how these styles operate under the hood is important. You still need to appreciate what adding and removing a class will actually do to the component you generate.
7. Separation of concerns
As I mentioned in the point above, JS libraries are popularising inline styles. The separation of concerns is a design principle for dividing a computer program into distinct sections. It involves encapsulating areas of your applications so that things don’t bleed into one another and confuse things.
The reality is that inline styles can get messy and confusing. Separating them into external files allows you to compartmentalize them more easily, it also keeps your markup a lot cleaner.CSS in JS is a modern way to overcome the problem and is a superior approach to just pure inline styles.
Do people use CSS anymore?
People use CSS all the time, it is the second most used language in the programming world alongside HTML. It drives more than 95% of websites on the internet today and is crucial to how we use the modern web. Learning CSS is an essential stepping stone to becoming a web developer.
However, CSS is not perfect. There are a few reasons why software engineers may try to avoid CSS in enterprise-level projects, these include:
- Global – In the world of React where we want everything to be compromised and compartmentalized, global styles can appear odd. Selectors run against everything in the DOM and things need to be accurately named to avoid any clashes or conflicts. With large projects, the global nature of selectors can be a pain and you may find yourself in a battle of styles.
- Maintenance – CSS can be a nightmare to maintain over a long period. Teams grow and change and people add various CSS properties over time. It becomes difficult to clean up CSS files and remove old stuff in fear that something will break. We strive for performant components but CSS flies in the face of this. It’s why CSS in JS has become so popular because CSS is kept at the component level.
- Modern alternatives – CSS-in-JS is providing a robust alternative to old-school CSS. It has all the power of CSS with preprocessors and none of the long-term drawbacks of bloat and control.
For all its drawbacks, software engineers are still using CSS en masse. However, they are switching to modern solutions to try and avoid the pitfalls of using pure CSS.