Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

give space above and below a DIV

Tags:

css

I want to give a DIV space above and under its content.

How can I do this using CSS?

my DIV code is:

<div class="input">
    <label for="pseudo">choisir un pseudo*:</label>
    <br>
    <input type="text" name="pseudo">
</div>
like image 434
Aimad MAJDOU Avatar asked Mar 15 '13 17:03

Aimad MAJDOU


People also ask

How do you put a space above a div?

In case you want additional space ( more than the default ) between div rows then you can add the following code before/after the start of the div row depending on where you want the additional space. This is easier but will add a fixed amount of gap.

How do I put top and bottom space in HTML?

The <p class="b"> element has a top and bottom margin of 20px. This means that the vertical margin between <p class="a"> and <p class="b"> should be 50px (30px + 20px).

How do you give a div text a space?

If you want to avoid CSS, you can use &nbsp; to force an extra space character, &ensp; for two spaces, and &emsp; for four spaces.


1 Answers

You use the CSS padding property. In your case you might want to use padding-topand padding-bottom alone.

The syntax is the following:

padding: top right bottom left;

or

padding: vertical horizontal;

Some examples:

// This will set the top space to 1px, the right to 2px the bottom to 3px
// and the left to 4px
.input {
    padding: 1px 2px 3px 4px;
}

// This will set both the top and the bottom to 20px and the right and the
// left to 10px;
.input {
    padding: 20px 10px;
}

// This will set only the bottom space, leaving everything else
// to be automatically determined
.input {
    padding-bottom: 20px;
}

Read more about the HTML Box Model

like image 104
Sunyatasattva Avatar answered Oct 17 '22 01:10

Sunyatasattva