What are differences and consequences (both good and bad) of using either data-src
or src
attribute of img
tag? Can I achieve the same results using both? If so, when should be used each of them?
What are differences and consequences (both good and bad) of using either data-src
or src
attribute of img
tag? Can I achieve the same results using both? If so, when should be used each of them?
The attributes src
and data-src
have nothing in common, except that they are both allowed by HTML5 CR and they both contain the letters src
. Everything else is different.
The src
attribute is defined in HTML specs, and it has a functional meaning.
The data-src
attribute is just one of the infinite set of data-*
attributes, which have no defined meaning but can be used to include invisible data in an element, for use in scripting (or styling).