Table of Contents

Headhunters are calling to you and want to check your skills as fast as possible. What are they asking about? Its rather simple questions but in some cases they know the tricky ones.

So what are they asking?

Question: (CSS)

Box model

Do you know the box model? Please list elements of box model.

This is the most fundamental knowledge about DOM and CSS. Elements of box model:

  • margin

  • padding

  • border

  • content

So when you have a box described with CSS:

.box {
width: 100px;
height: 200px;
border: 10px solid #000;
margin: 20px;
padding: 30px;
}

what is total width/height and total height of the box?

total_width = width + border_left + border_right + padding_left + padding_right + margin_left + margin_right

so in this case it is

total_width = 100 + 10 + 10 + 20 + 20 + 30 + 30 = 220 (px)

total_height = height + border_top + border_bottom + padding_top + padding_bottom + margin_top + margin_bottom

so in this case it is:

total_height = 200 + 10 + 10 + 20 + 20 + 30 + 30 = 320 (px)

How can we omit problem of counting total width and height? Use a box-sizing in CSS.

Question: (CSS)

Clearfix

What is clearfix?

This is mostly connected with floating elements in HTML / CSS. In case you have a container with floating elements you need to clear floatings in the last element of childrens of this container. In oldschool way:

HTML code:

<div class="container">
<div class="floating"></div>
<div class="floating"></div>

<div class="clearboth"></div>
</div>

CSS

.container {}
.floating { width: 100px; height: 100px; float: left; }
.clearboth { clear: both }

Now when you have :before and :after pseudoelements you dont need to waste one more tag in HTML for clearing floats. You just need to add a CSS to container:

.container:before,
.container:after {
  content: "";
  display: table;
}

.container:after {
  clear: both;
}

or create a standard reusable clearfix in same way:

.container:before,
.clearfix:after {
  content: "";
  display: table;
}

.clearfix:after {
  clear: both;
}

Categories

Recent Posts

About Me

Piotr Sikora - Process Automation | AI | n8n | Python | JavaScript

Piotr Sikora

Process Automation Specialist

I implement automation that saves time and money, streamlines operations, and increases the predictability of results. Specializing in process automation, AI implementation, and workflow optimization using n8n, Python, and JavaScript.

n8n Workflows

n8n workflow automation templates

Explore my workflow templates on n8n. Ready-to-use automations for blog management, data collection, and AI-powered content processing.

3Workflow Templates

• Auto-Categorize Blog Posts with AI

• Collect LinkedIn Profiles

• Export WordPress Posts for SEO

Similar Articles

Discover more related content

Master SASS Installation with This Quick Guide

Ever dreamed of variables or functions in CSS? The easiest way to get them is by using a preprocessor like SASS.

Test Your Mastery: Challenge Your Knowledge of CSS Selectors

Do you want to check your fundamental knowledge of FEDev? Check it out! Run it and test your knowledge about selectors.

Pure CSS Collapsible Elements: Create Accordion

Learn how to create collapsible elements and accordion components using pure CSS-no JavaScript needed