I am wondering what is the difference between two following:
<
There are lot of pros and cons in both these approaches depending on the element and condition it should load/render. I don't think all of them can be explained in a single answer without giving various references in it.
You can find such answers in the following questions:
What's the difference between HTML's and CSS's width attribute?
What's the difference between the HTML width / height attribute and the CSS width / height property on the img element?