Ignore margin in case div is empty
I have 2 DIVs aligned horizontally next to each other and centred using a wrapper. I use margin-right to separate DIV2 from DIV1. DIV2 could have no content. In case DIV2 has no content, i want the margin to be ignored and DIV1 to be centred alone.
This is my CSS:
This is HTML: p
I created a fiddle for you to play with: http://jsfiddle.net/wfrcG/3/
You could use the
:empty pseudo class to set the margin to
0 if the element is empty.