How to add some default margin on each element of a div?

Hi there

This is my jsfiddle.net
http://jsfiddle.net/vngx/tyd5zkfk/2/

I want some default margin on each element of a div when I am coming down

one approach I am thing is make a class attribute and assign that to each element.

Is there any alternative of this

Div? Do you mean the inputs?

yes i mean input not div

div * { margin:10px; }
1 Like

I would avoid megazoids solution, although it looks like every input there needs space. Perhaps add in this:

#main_block input { margin-bottom:5px;}

I also don’t see where your form element is…all of that is a form so it should be inside of a form.

1 Like

thanks but If I want margin to be only that place I have mention in my jsfiddle?

your approach is good but it is giving each element margin

The best solution would be wrap each pair of <label> and <input> in some div with class
and then add margin to this class

This is first approach that I was thinking but this will create 40 divs in my HTML page which sounds a little odd for just one thing I am making div

I fixed your HTML.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.