CSS is not a programming language, it is a style sheet language that we use to tell the browser what we want our HTML to look like. CSS is incredibly important and is used to define the appearance of more than 95% of all websites online today. Regardless of its status as a programming language, CSS is vital in modern software engineering.
The argument over whether CSS is a programming language is quite hotly contested. It has some features of a programming language, like being Turing complete, but lacks most of the basic functionality to be considered one.
However, much of the debate that surrounds the status of CSS is due to the way it is used to devalue certain developers. Often programmers who use ‘proper’ languages will cite the use of CSS to make software engineers feel inferior about their tech stack or that their work isn’t valuable.
First, let’s explore what CSS is used for. Then we’ll take a look at why CSS is not a programming language and understand why it doesn’t matter.
What is CSS used for?
Cascading style sheets, or CSS for short, is a style sheet language. It describes the presentation of markup languages, which in web development is usually HTML. If HTML is the building block of a web page, CSS describes how they are presented and decorates your users.
It’s an incredibly domain-specific language that is only used in your device’s web browser.
Although it is primarily used with HTML, it is in fact compatible with any XML-based markup language.
Is CSS a programming language?
CSS is a custom stylesheet language, not a programming language. Every modern website uses CSS and it is critical to the way we interact with the web. CSS is used to define the appearance of your markup rather than to build software or applications.
The importance of CSS for the web can’t be overstated. However, as important as it is, CSS does not function as a programming language. Many people do think of it as a programming language because of its technical nature. The lines between what is and isn’t a programming language can sometimes be very subjective, especially with developers intent on proving they use a ‘real’ language.
Discussing why CSS is not a programming language can get controversial because it is often used by some developers to elevate their status over others.
Let’s delve into the subject a bit deeper and look at why it’s not seen as a classic programming language.
Presentation vs function
We use CSS to style our HTML and other markup languages. Its purpose is to dictate the appearance and presentation of our web pages. It can’t strictly perform calculations or run functions that cause something to happen. In contrast, with programming languages, you can write code that performs tasks and completes instructions.
Style sheet languages like CSS are concerned with how things are presented, not how they function. CSS doesn’t contain instructions or tasks for other elements of your application to carry out. Programming languages describe function whereas CSS describes presentation.
However, there are some exceptions to this. CSS accepts calc() which is essentially a math function. Media queries are the CSS version of a switch statement, and custom properties are a light way to store some state.
There are now a variety of functions in CSS which means you argue it has grounds to be considered a programming language in its own right.
For a long time, it was argued that CSS couldn’t be considered a programming language because it was not Turing complete. However, this stance has been reevaluated recently. Laura Schenck wrote an in-depth article on the topic and I’ve linked it at the bottom of the article if you want to check it out.
Essentially CSS+HTML combined is actually Turing complete because you can encode Rule 100 in CSS. However, it’s unlikely you’ll be writing programs in CSS and HTML. It’s incredibly difficult and not practical.
A different type of language
CSS is considered a stylesheet language rather than a programming language. It can’t function without any markup to style and is, therefore, dependent on HTML. CSS decides how your markup is presented rather than what it does or how it behaves.
Many are arguing for it to be considered a domain-specific programming language rather than a general programming language. SQL is another example of a domain-specific declarative language that can’t be used as a general-purpose programming language. But nobody bemoans SQL developers as not being ‘real’ programmers.
The way JS and CSS are told to run is similar to. One requires a <link> tag and the other a <script> tag. So while they achieve different things, both have to be run by the browser to function properly.
Whether you are happy to make this distinction will depend entirely on your opinion on whether CSS has the firepower to be considered a programming language. But whatever your views, don’t look down on others using the language.
Does it matter if CSS is a programming language?
It doesn’t matter whether you consider CSS a programming language or not, what is important is to treat all software engineers with respect regardless of the technologies they choose to use. Plenty of the dividing lines we draw in tech is arbitrary with different languages having different facets to compare.
What is important is to treat developers who use different technologies with respect, regardless of your opinions on the tech stack they use.
The problem with asking if CSS is a programming language is that the question rarely comes from a place of kindness. Often people want to classify what is a ‘proper’ or ‘real’ programming language to the detriment of other software engineers.
People are keen to prove they are doing the real development work while others are working on projects using two-bit languages. It drives unnecessary divisions between a group that could eventually unionize.
The reality is that while CSS is a style sheet language and not a programming language, it doesn’t make anyone less of a developer. It devalues the hard work that people put in to make beautiful products and shouldn’t be something we accept in software engineering.
It’s a tough pill to swallow when you have invested a lot of time and effort into a skillset that isn’t paid as highly. Usually, this comes from programmers who have learned a low-level language but feel they aren’t being fairly compensated.
It’s important for hiring managers to be able to distinguish between the technical skills of the people they hire. Getting the right people for the right job is crucial. Hence why some people are so keen to establish their technical skill sets.
At a high level, some managers may not know the differences between programming languages so declaring you know how to program if you just know some CSS may be misleading or confusing.
In all honesty, though, that is a poor excuse for undermining another person’s technical skillset.
Is CSS a markup language?
CSS is not a markup language, it is a style sheet language that is used to define the presentation of markup languages like HTML. Markup languages are used to let your devices how you want elements on the page organized but CSS is used to style these elements. It affects appearance but relies on a markup language to be effective.
Without markup like HTML, CSS would be useless. CSS styles HTML elements and tags whereas markup languages define and organize the layout of a web page. Cascading style sheets define the appearance of markup rather than its functionality.
CSS is not a programming language but it is essential in enabling the web as we know it to function. Whether we classify it as a programming language can be subjective but the reality is that 95% of web pages use it and without it, we’d be worse off.
It may not be as formidable as ‘real’ programming languages but it doesn’t make its practitioners any less skillful. For too long sticky programming languages into specific boxes has been a way to elevate or demote certain software engineers. We should strive to treat every element of development with the respect it deserves.