April 13, 2012

How to control a <label> with CSS?

Question by AAA

I have this snippet:

      <label>&nbsp;</label><a id="whatever" 
      onclick="addmore('field_whatever', 'What's up?');">The deal is?</a><br/>

How do i use CSS to add space on the top or the bottom. I am able to do it for margin-left but it won’t work for margin-top nor margin-bottom.

Thanks

Answer by Starx

labels are by default inline. They will not respond on top/bottom margin. You have to tell them to display as block/inline-block .

Like this

label { 
    display: inline-block;
    margin: 20px 0;
}

Additionally, your anchor has an un-escaped quote. Correct it as this

<a id="whatever" 
      onclick="addmore('field_whatever', 'What's up?');">The deal is?</a>
...

Please fill the form - I will response as fast as I can!