what is the difference between <hr width="px" /> and <hr width="%" />? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

what is the difference between <hr width="px" /> and <hr width="%" />?

i could not differ the px and percentage in attribute measurements,if some can tell me what is the difference and how can i use it? thank you!

5th Jun 2017, 12:24 PM
A.RAHMAN
A.RAHMAN - avatar
3 Answers
+ 12
Yep, in short: The percentage is variable, it can depends on the container size (body, div and so on), it could be helpful in responsive websites. The pixel value is fixed, it could be helpful for set fixed value, for example in a canvas.
5th Jun 2017, 12:32 PM
Maz
Maz - avatar
+ 7
Technically there's no difference, because 'width' attribute is deprecated in Html5, as almost of styling attributes which are intended to be replaced by Css styling... However, @Maz answer is still valid for Css units, and even for 'width' html attribute, as Html is permissive and browsers are expected to correct bad syntax as well as they can (so implicitly, html 'width' attribute is corrected by being auto replaced by 'width' Css property ;) ). But it's strongly recommended to no more use html attributes for styling elements ^^
5th Jun 2017, 1:36 PM
visph
visph - avatar
0
OK , I got it. thank you! :p
5th Jun 2017, 12:42 PM
A.RAHMAN
A.RAHMAN - avatar