How to Avoid White Space in HTML Using Div

How to Avoid White Space in HTML Using Div thumbnail
CSS styles help you control your data display.

HTML DIVs are block elements that group other HTML data. You can manage the data contained within a DIV as a group, for example, with CSS styles. CSS enables you to set various attributes such as borders, background color and position. Use a CSS style inside a DIV to control the white space around your HTML elements.

Instructions

    • 1

      Launch your editor and open your HTML document.

    • 2

      Enclose your content with beginning and ending DIV tags:

      <div>

      <h1>A First Level Heading</h1>

      <p>A paragraph of text</p>

      </div>

    • 3

      Insert a style for "margin-top" with negative spacing in the DIV to subtract space from the top of the block:

      <div style="margin-top:-6px;>

      <h1>A First Level Heading</h1>

      <p>A paragraph of text</p>

      </div>

    • 4

      Save the file. Use the Preview option of your editor or open the page inside a Web browser to view the results of the style change.

Related Searches:

Resources

  • Photo Credit Jupiterimages/Comstock/Getty Images

Comments

Related Ads

Featured