HTML | Padding in px versus %

|
| By Webner

In HTML, padding can be given to the text in following ways:

Method 1:

style=”padding-left:100px;”

or

style=”padding-right:100px;”

Method 2:

style=”padding-left:30%;”

or

style=”padding-right:30%;”

It is more appropriate to use “%” than “px”. The reason for this is when px is used, padding space is fixed on screen of every size. It will look good when the size of the screen is large. But when the same page is viewed on smaller screen, image does not resize or adjust itself accordingly. In other words, responsiveness is not achieved.

When “%” is used, image adjusts to the size of the screen on which page is viewed and responsiveness of the page is not affected.

Leave a Reply

Your email address will not be published. Required fields are marked *