Skip to content Skip to sidebar Skip to footer

Is There A Way To Have A "line Break" Between Divs?

So I have a menu, 4 menu points and I want to put them in a square 2x2. Is there a way to do that WITHOUT having a class for the first two and one for the other ones? Thanks for an

Solution 1:

Sure. For one, you can use floating and set the widths accordingly. See the example below, or http://jsfiddle.net/BUPX7/ for a live example.

HTML

<ul>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
    <li>Item 4</li>
</ul>

CSS

ul {
    width: 200px;
}

ulli {
    width: 100px;   
    margin: 0;
    padding: 0;   
    float: left;
}

Solution 2:

There is a line break between div elements by default. You are apparently using some CSS to override that. You need to modify the CSS code accordingly, or select a different approach.

The simplest way, assuming ”menu points” are links, is to use

<div><a ...>link1</a> <a ...>link2</a></div>
<div><a ...>link3</a> <a ...>link4</a></div>

But if you are using some elaborated markup and wish to create the break in CSS alone, then you may need some elaborated selectors like :nth-child(3).

Post a Comment for "Is There A Way To Have A "line Break" Between Divs?"