views:

42

answers:

1

Here is two spans(in real life a lot of spans) situated at the web page. I would like to set the distance betwwen them. I want to use margin-bottom attribute for this, but I can't see any affect of using it. The spans are still on the previous position. That is wrong. Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title></title>
    <style type="text/css">
        .position, .name{
            overflow: hidden;
        }

        .position{
            margin-bottom: 40px;
        }
    </style>
</head>
<body>
    <span class="position">Designer</span><br/>
    <span class="name">John Smith</span>
</body>
</html>
+1  A: 

span is an inline element, not a block element, and they don't respect margin. You can use padding or make the span display:inline-block; and then use margins. The latter is now supported in most somewhat newer browsers.

Pascal