Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are all the differences between src and data-src attributes?

Tags:

html

image

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?

like image 658
Adam Pierzchała Avatar asked Mar 10 '13 07:03

Adam Pierzchała


People also ask

What is a data src attribute in HTML?

The src attribute specifies the location (URL) of the external resource.

What is data SCR?

Summary Care Records (SCR) are an electronic record of important patient information, created from GP medical records. They can be seen and used by authorised staff in other areas of the health and care system involved in the patient's direct care. Using SCR.

Is src an attribute or property?

The HTMLMediaElement. src property reflects the value of the HTML media element's src attribute, which indicates the URL of a media resource to use in the element.

What is the value of src attributes?

The <img> src attribute is used to specify the URL of the source image. Attribute Values: It contains single value URL which specifies the link of source image.


1 Answers

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).

like image 69
Jukka K. Korpela Avatar answered Oct 03 '22 21:10

Jukka K. Korpela