What problem does CSS solve?

Experience Level: Junior
Tags: CSS

Answer

The CSS (Cascade Style Sheets) is used together with HTML (Hypertext Markup Language).

  • The HTML is used to define the web page content - Structure and information
  • The CSS is used to define what things should look like - Look and Feel

Using HTML for styling is not good

You can use HTML to define look and feel as well, but it is difficult to use HTML for styling because styling HTML code needs to be used on many places and it gets repeated again and again. The web page than gets bloated and is difficult to maintain. If you need to change a style, you need to do it on many places, which is very time consuming and error-prone.

CSS solves the styling problems of HTML

To fix the problems above, CSS was created.

Separation of concerns

CSS code is separated from HTML. It is defined in one central location and affect many web pages and their elemens. Due to isolation you always know where the CSS is and it is not mixed with other technology so it more readable (has better readability) and easier to maintain (has better maintainability)

DRY principle (Do not repeat yourself)

The CSS style is defined once and applied multiple times. You can change the CSS code in one location and affect many web pages and their elemens without changing all pages one by one. So you don't repeat yourself and you don't duplicate same thing over and over again.. Thanks to the reusability you save your time.

Related CSS job interview questions
CSS for beginners
CSS for beginners

Are you learning CSS? Try our test we designed to help you progress faster.

Test yourself