How to Hire a Great CSS Developer
Cascading Style Sheets, or CSS for short, is a style sheet language used to describe the presentation of a document written in HTML. The first version of CSS was proposed in late 1994. Over the next 20 years, CSS was upgraded 3 times, leaving us with current CSS version 3. Today, CSS is one of the core languages of the web and it is standardized by a W3C specification. Its development was very slow, which resulted with problems in adoption, and in the end web browser developers took things into their own hands. This resulted in many cross-browser compatibility issues and wasted development hours. CSS3 in hand with HTML5 has become an integral part of any front-end development, and there is no shortage of developers with CSS listed on their resumes. This makes locating CSS developers fairly easy, but makes choosing the perfect one that much more of a challenge. Many web developers will say they are also CSS developers, but as with any language or skill, there’s a difference between knowing CSS and being a CSS expert.
That’s why hiring CSS developers can be difficult, and searching for a perfect one could be long and daunting task. It doesn’t have to be like that - the goal of this guide is to help you find the perfect match for your team or project. Toward that goal, this article offers a sampling of questions that are key to evaluating the breadth and depth of a candidate’s mastery of CSS. The following guide gives you some questions for inspiration when preparing an interview for top-notch CSS developers. You should not assess candidates based purely on their ability to “correctly” answer each question. That would be missing the point, because not every top candidate will know all the CSS details, nor does knowing all the details guarantee you the best developer. Instead, use provided questions to see how the candidate thinks about the problem at hand, how they work through provided examples, and how they weigh alternatives and make judgment calls.
Questions and Answers
Q: What is an ‘id’ selector, and what is a ‘class’? Explain their differences.
HTML elements can have either
id attribute or
class attribute, or even both attributes.
id selector assigns a unique name to the element it is applied to. For CSS to be valid, there can be only one element with a given name. An
id selector is usually used when you want to restrict styling rules to a specific HTML element, or a block of elements. By the CSS specification,
id selectors are defined with the
# character, followed by the name.
On the other hand, the
class attribute assigns a class name to the element, and that name can be used on any number of elements within the document. A class-specific style is used when you want to apply styling rules to more than one of blocks and elements within the document. Similar to
id selectors, classes are defined by a period (
.) and followed by the class name.
To summarize, an
id selector identifies and sets style to only one occurrence of an element, while
class can be attached to any number of elements. CSS best practice is to to use classes as much as possible, and to reserve the use of
id attributes for specific uses. This will result with smaller style sheet files which are more performant and easier to maintain.
Q: In how many ways can CSS be added to a web page? Discuss advantages and disadvantages of each approach.
There are three ways to include CSS to a web page:
- Inline: CSS is applied directly to the HTML elements by use of the style attribute.
- Embedded: CSS is added within the
headelement of the web page by placing the CSS code in a
- External style sheets: CSS is placed in an external file and added to a web page by use of a
Inline styles have more disadvantages than advantages. Inline styles are useful for small numbers of style definitions and they have the ability to override other style specifications. The disadvantages are they don’t separate the style from the content, styles can’t be controlled from one place, and it is hard to create more complex styles.
Embedded and external CSS share most of the advantages over the inline styles. It is possible to create classes that will be used by multiple elements in the document, they allow complex styling by using selector and grouping methods, and styling is controlled from only one place.
By using embedded style sheets no extra download is required, while external CSS files offer style control of multiple HTML documents from a single file. Disadvantage of the external CSS file is until the external style sheet file is loaded, the HTML document can not be properly rendered.
Q: Explain what RWD is. Discuss how it can be achieved with CSS.
RWD is an abbreviation for Responsive Web Design, and it is the practice of building web pages to work on any device and every screen size; no matter how large or small they are, be it a mobile phone, tablet, laptop or desktop. Benefit of the RWD is you don’t need to create a different page version for each mentioned device. Responsive web design uses only HTML and CSS to resize, hide, shrink, enlarge, or move the content to make it look best on any given screen. RWD is achieved by using CSS media queries - media queries are simple filters which make the content style change based on the characteristics of the device like the display type, width, height, orientation and even resolution.
Q: Discuss CSS image sprites.
CSS sprites are essentially multiple raster images merged into a single image. The main reason for their usage is to help with performance. The fewer different requests a browser needs to make, the faster the web page will load. Term “sprites” dates from the old times and was first used in video games. The idea was that it is faster to load one image into graphic memory, and then only display parts of that image at a time, than continually load new images. This same principle is used in web today.
In CSS, image sprites are used with a
background-image property, and then adjusted by setting the background position and dimensions of the individual classes to display a single portion of the complete image sprite.
Q: Explain what Less, Sass, and Stylus are. Discuss what they offer, and their advantages and disadvantages.
Less, Sass, and Stylus are all CSS preprocessors. CSS preprocessors are an abstraction layer on top of CSS, written in a special syntax compiled back to CSS.
CSS preprocessor offer powerful features on top of the CSS, with variables, extends, and mixins being the most notable. Variables store information that can be reused later, like colors or other commonly used values. Extends help you create “classes” that allow inheritance for the rules. Mixins, you can think of like “function”. There are some other features in comparison with vanilla CSS, like the use of logic statements (conditionals and loops), custom functions, integration with other libraries like Compas, and many more.
When talking about advantages and disadvantages, personal preferences offer great opportunity to discuss with the candidate their own view on the use of CSS preprocessors and reasons why a specific one could be used. Basically, there is no right or wrong answer why which one could be used. To read more about CSS preprocessors, you can read an article Why You Should Stop Using Vanilla CSS.
Q: Explain what CSS vendor prefixes are.
CSS vendor prefixes are extensions to the CSS standards. They are used by browsers to offer experimental and non-standard features. Since the vendor prefixes are not included in the official CSS specification, by adding specific prefixes browsers are preventing future incompatibilities which could arise when the standard is extended.
The CSS vendor prefixes are:
- Internet Explorer:
Q: Explain the CSS box model and the layout components that it consists of. Provide examples.
The CSS box model is a rectangular layout paradigm for HTML elements that consists of the following:
- Content - The content of the CSS box, where text and images appear
- Padding - A transparent area surrounding the content (such as the amount of space between the border and the content)
- Border - A border surrounding the padding (if any) and content
- Margin - A transparent area surrounding the border (such as the amount of space between the border and any neighboring elements)
Each of these properties can be specified independently for each side of the element, namely top, bottom, right and left, or they can be combined into multiple sides by specifying fewer parameters. For example:
/* Setting top, right, bottom and left margin */ margin: 50px 10px 100px 25px; /* Setting the same margin on all four sides: */ margin: 50px; /* Grouping together top/bottom margin and right/left margin */ padding: 100px 25px;
Test candidates with CSS examples, or give them tasks to create HTML elements using only CSS
You can test candidates by giving them different CSS examples and asking them to explain what they do. This way you can better assess their way of thinking and knowledge about some CSS specifics. Another approach is to give candidates an image of some fancy button or a progress bar, and ask them to recreate them using only CSS. Some CSS examples you can give out to candidates are listed below.
Q: Explain what elements will match each of the following CSS selectors:
span > a
span + a
span ~ a
span, awill select all
<span>elements and all
span awill select all
<a>elements that are anywhere inside a
span > awill select all
<a>elements where the immediate parent is a
span + awill select all
<a>elements that are placed immediately after a
span ~ awill select all
<a>elements that are anywhere preceded by a
Q: Explain the meaning of each of the following CSS units:
- cm - centimeters
- em - elements, relative to the font-size of the element (e.g., 2 em means 2 times the current font size)
- in - inches
- mm - millimeters
- pc - picas - 1 pc = 12 pt = 1/6th of an inch
- pt - points - 1 pt = 1/72nd of an inch
- px - pixels - 1 px = 1/96th of an inch
Q: In CSS3, how would you select:
<a> element whose href attribute value begins with
<a> element whose href attribute value ends with
<a> element whose href attribute value contains the substring
- Select every
<a>element whose href attribute value begins with
- Select every
<a>element whose href attribute value ends with
- Select every
<a>element whose href attribute value contains the substring
For a top CSS developer, provided questions might come off as a bit basic. However, they cover most of the core CSS concepts and principles, and they do provide a starting point for evaluating individuals. Being able to discuss CSS principles and concepts in a clear and coherent manner will demonstrate candidate’s communication skills as well as their theoretical and peripheral subject knowledge. Finding true masters of CSS is a challenge. We hope you find the questions presented in this post to be a useful foundation in your quest for the elite few among CSS developers. Finding such candidates is well worth the effort, as they will undoubtedly have a significant positive impact on your team’s productivity and results.