How to Set DIV Height & Width

Save

A division (div) divides an HTML area into individual sections. Each section can then have its own formatting. Website designers commonly use the div tag to assign "class" or "id" attributes, which link to Cascading Style Sheets (CSS) files. The height and width of a div element can be set within the div tag itself.

  • Open Notepad or your preferred text editor.

  • Open the HTML file where the div tag you want to edit is located.

  • Add the height and width properties to the <div> tag using the format "height:Xpx; width:Ypx;", where "X" and "Y" are numbers. For example, a div tag could look like <div style="background-color:blue; height:200px; width:100px;">. Alternatively, you could instead specify the "max-height" or "min-height". Make sure you include an accompanying "</div>" tag after your HTML.

  • Save the file and load it in a browser to check that it's displaying properly.

References

Promoted By Zergnet

Comments

You May Also Like

Related Searches

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!