How Do I Get Margins on My Website in HTML?

As you build your website pages, create cushions around the body of your content so that your work is not pushed up against the edge of a browser window. These areas known as “margins” allow you to specify spaces around the top, bottom, right and left side of your page so that your presentation is more attractive to the viewer and easier to read on the Web. Using a Cascading Style Sheets (CSS) rule in conjunction with your HyperText Markup Language (HTML), provide margins for your website to improve your display.

Things You'll Need

  • Text editor
Show More

Instructions

    • 1

      Launch your text editor and place your cursor between the “<head></head>” tags in the HTML code.

    • 2

      Enter the CSS entry that works with your HTML “<body>” tag to format the layout of your page:
      <style type=”text/css”>
      <!--
      body { }
      -->
      </style>

    • 3

      Type in the “margin” attribute inside the curly brackets and specify values in a measurement like pixels (px) or percentage (%). Each number stands for the “margin-top,” “margin-right,” “margin-bottom” and “margin-left” and corresponds to the order that these digits are typed in. For example, to create a page that has a “margin-top” of 10 pixels, “margin-right” of 20 pixels, “margin-bottom” of 10 pixels and “margin-left” of 20 pixels, enter the following:
      body { margin: 10px 20px 10px 20px; }

    • 4

      Open your Web page in a browser window to preview your work and then save your file when done.

Related Searches:

References

Resources

Comments

You May Also Like

Related Ads

Featured