Setting height of HTML elements as PERCENTAGE

You can easily set the width of an HTML element as percentage of its container using the following syntax:

<div style="width:10%">

This will set the width of the div as 10% of the container’s width.But you cannot set the height of the <div>(or any other element) using the specified syntax only. You need something more. Put the following code in the <style>-tag:




Then your inline style i.e. <div style="height:10%"> definition will work.

So keep this in mind when you want to set the height of any specific element as the percentage.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s