How to Set the Width of a DIV

DIV means division in HTML. Using DIV tags allows you to style an element differently than other elements in a page. For example, you can align a particular element to the left or right, or you can change its font size or color. You can also edit its background and change the width and height of the element. If you want to change the width of the element, you can do so using basic DIV styling prompts.

Instructions

    • 1

      Type your opening DIV tag as "<DIV style ="width: 50px">" (without the outside quotes).

    • 2

      Replace the "Px" value with one that suits the width needs of the element in pixels. For example, if you want to make the width 300 pixels, input "300px" instead of 50px.

    • 3

      Input the text or element that is part of the division following the opening DIV tag.

    • 4

      Type "</DIV>" (without quotations) following the element's code or script to close the division.

Tips & Warnings

  • You can add additional styling elements to the DIV tag as well. For example, if you wanted to float the element to the right side of the section, include "float:right" (without quotations) before the last quotation mark following the element's width. Be sure to include a semicolon between each styling prompt or command.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured