In this article, I will present some of the most frequent questions and answers made by interviewers. There will be questions about HTML & CSS. If you like reading, go ahead. If you don’t, you can still watch myself answering the same questions in this YouTube playlist I prepared.

1. What is CSS selector specificity and how does it work?

<iframe width="560" height="315" src="https://www.youtube.com/embed/JtZ3SFsYTeA" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
When you are working with CSS selectors, there are many different ways you can select a certain element or group of elements, but there are four categories: Inline styles (1000), IDs (100), classes (10), and elements (1).
Did you notice the numbers? This is something few programmers know, but they represent the specificity of each category. The bigger the number, the higher the specificity, and it adds up! For example, if you use 
#home h1
, the specificity would be 
100 + 1 = 101
, which would be more than only
#home
 .

2. What is accessibility? How do you make your web application the most accessible?

On a webpage, high accessibility means that all of your users will have the same experience, regardless if they are using different devices or have a vision impairment, for example.
There are multiple implementation details you should make in order to make your webpage the most accessible, let me give you some examples:

3. What is progressive rendering?

Progressive rendering is the act of slowly rendering the data in a webpage, in order to increase the user experience if their internet connection or device is too slow. I can give you three examples of what can happen when a webpage is doing a progressive rendering:

4. What is progressive enhancement?

In the last example of the last answer, I mentioned that a webpage uses progressive rendering to load first the HTML, then the CSS, and finally the Javascript. This is the definition of progressive enhancement.
First, the programmer plans the project’s foundation and structure (HTML). If it is working properly on a webpage (the user can see the content properly), then an enhancement is made, the programmer adds CSS. After adding CSS, the programmer can add more complex features to the webpage by adding Javascript. If the webpage breaks, if the user has disabled Javascript, for example, the styled content can still be seen.

5. Explain your understanding of the box model and how you would tell the browser in CSS to render your layout in different box models.

The box model represents the way elements behave on the webpage and interact with each other, regarding some of their properties, like width, height, margin, padding, and border. There are also different display types for each element, like block, inline-block, flex, grid, etc that will change their positioning on the page.
In terms of sizing, the elements’ standard behavior is given by the following equation:
total = width + padding + margin + border
If you don’t want to have issues with your layout when determining the real width of it, you can use 
box-sizing: border-box
 , this way the total width of your element will be the one you specify, regardless of the amount of border, margin, and padding.
In terms of positioning, the elements’ standard behavior depends on the type of it. For example, a 
div
 element has 
display: block
 if not specified in the code, and an 
a
 element has a standard
display: inline-block
 . If you want to change these elements’ behavior, you need to specify it.

6. What are the various clearing techniques and which is appropriate for what context?

Let’s first understand what are floated elements. When you 
float
elements, they will affect other elements’ positioning that is in the same container. For example, you have two images and some text between them, then you give the first image 
float: left
 , and the second one
float: right
 . The text would flow around the images.
The 
clear
 property determines whether floated elements can’t exist besides the cleared element, it can clear left, right, or both sides. In the image above, we might not want the text to the right of the left image, or to the left of the right image. We have some techniques that could be used to fix this:
I hope you could learn something by reading this article. These are only some of the HTML & CSS questions out there, you can check this link for more examples.
This article is the 1st of a series of articles I will be writing. The next article will feature Ruby interview Q&As, I will update the links in this article when I finish the next ones.
If you liked this article, make sure to: