AI Workshop: learn to build apps with AI →
CSS Tips: How to debug CSS by bisecting

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


I had this problem once.

I added the Paddle button to my online course page, so people could click the “Buy now” button and the nice Paddle popup would show up.

The popup has a loading indicator, a circle with a spinner inside, and there was an issue: when clicking the “Buy now” button, the spinner indicator was not centered inside the circle, as shown in this gif:

I didn’t really know what was causing the issue, so I was thinking how to solve it.

The principle I use in these cases is bisect. I also call it divide et impera.

I opened the DevTools and moved to the Sources panel, which showed all the files loaded in the page. I searched for one of my CSS files, as my intuition was that the page CSS was interfering with Paddle’s own CSS rules.

So I removed all the content of that file.

Chrome automatically changes the appearance of the page when you alter the CSS files in the Sources panel, so I was able to check and see that the spinner was now working fine!

So, one of the rules in that CSS is the problem.

How do I find out which line?

The file has 312 lines. I select from line 150 to 312 and delete it. Try again. The problem is still there, so it must originate from the first 149 lines.

I hit cmd-Z (undo) to put back those lines I removed, and delete lines 70-149.

The problem is gone, so the problematic line is in there. I hit cmd-Z again to restore the lines I deleted.

You get the idea—rinse and repeat until you find the line that causes the problem.

Lessons in this unit:

0: Introduction
1: How to center an element with CSS
2: CSS Border inside the element
3: What are good CSS Breakpoint values for Responsive Design?
4: ▶︎ How to debug CSS by bisecting
5: How to disable text selection using CSS
6: How to put an item at the bottom of its container using CSS
7: CSS, how to select elements that do not have a class
8: How to stick an element on the bottom of the page with flexbox
9: How to apply padding to multiple lines in CSS
10: Making a table responsive using CSS
11: CSS url()
12: How to make an element smaller or bigger with CSS
13: Customizing visited links
14: Fix extra space after inline element
15: How to create a sidebar that’s sticky but also scrolls
16: How to embed YouTube videos using the correct aspect ratio
17: Responsive pre tags in CSS
18: Responsive YouTube Video Embeds
19: How to remove all CSS from a page at once
20: How I added Dark Mode to my website
21: How to add a simple dark mode