Skip to content Skip to sidebar Skip to footer

What's The Best Way To Add A Line Break Before And After Div?

Someone shows me a html to use div tag to show some text with background image included
SOME TITLE TEXT

Solution 1:

You can give margin from top and bottom like this:

margin: 10px 0;

Above will apply 10px margin from top and bottom. You can also use individual properties such as margin-top and margin-bottom.


Solution 2:

one way is to use css to style your elements.

<style>
.main
{
  margin-bottom: 10px;
}
</style>

you can alter as needed..not sure what div's you want to seperate


Solution 3:

There are 2 main ways to add line breaks: through line break <br> tags and through paragraph tags <p>. So all you have to do is to put those tags in between your tags.


Solution 4:

Add the child divs to span like below

<div class="class1" >
   <span class="span1">
         data1 
       <br>
       <span class="span2">
            data2
       </span>
    </span>
</div>

css:

   .span1{
      display:inline-block;
    }
    .span2{
      display:inline-block;     
    }




    </div>

Post a Comment for "What's The Best Way To Add A Line Break Before And After Div?"