Need of colors for different css

Two examples:
1.
I need colored backgrounds on a page in four colors.

I need colored backgrounds on a page with any color i want.

What is the best way to do that?

For 1. i can add four blocks in four colors?
For 2. i can add blocks with an input field for the wished color?

For understanding:

lalala
would be the result done with style for example 2

or something like:

… for example 1.