CSS FizzBuzz, has science gone too far?

  • by Amando Abreu
  • on 14 August 2017

Recently at an interview instead of checking whether or not I had a pulse, it was requested that I solve the FizzBuzz challenge in a language of my choice.

Naturally, I chose CSS.

“Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.”

It’s insanely simple.

To not display the number, for every 3rd and 5th element, set the font-size to 0.

li:nth-child(3n), li:nth-child(5n){


To display Fizz for every multiple of 3, for every 3rd element, write “Fizz” with the :before pseudo element.


    content: 'Fizz';


To display “Buzz” for every multiple of 5, for every 5th element, write “Buzz” with the :before pseudo element.

    content: 'Buzz';

“FizzBuzz” comes for free whenever every 3rd and every 5th elements are the same.

See the Pen CSS FizzBuzz by Amando Abreu (@amando96) on CodePen.

About the author

Amando Abreu got into electronics as a kid, started programming microchips in his early teens, moved onto web development in his late teens, and got into people; psychology; and business in his twenties. Currently co-founder & CTO @ Perlo.io
No comments, just