All music is based on an underlying pulse, or beat.
It can be very obvious, like in Rock music, or not so obvious like in some Impressionistic music e.g. This is what makes us want to dance and move to the music- or not!
Different rhythms are layered “on top of” the beat. This can be easy simple rhythms or complex music rhythm patterns like for example in Latin music.
This beat (imagine the circles as a beat or pulse);
O O O O O O O O
is all the same. Try tapping with your hand a steady beat on the table or on your leg.
Now tap harder on some of the beats, like this (X marks the harder beats):
X O O O X O O O
By doing this, the beat automatically feels organized in groups, in this case in groups of 4. This is also called meter in 4!
Now try this:
X O O X O O X O O
This would make meter in 3!
X O X O X O X O
(-Not hugs and kisses!) Would make meter in 2.
So, what has all this got to do with bar lines? Well, bar lines are placed right before the X! Let’s swap the O’s and X’s with notes. Like this:
Hmm… just notes. No indication of the beat. So we add lines! This tells us that the note on the first beat after the bar line is supposed to be heavier, or a bit louder ("downbeat").
But this example has a rather boring rhythm. Each beat can have a lot of different rhythms “on top of it”. As long as all the note values add up to the same for each beat.