/

HTML / CSS / JavaScript Tutorial

HTML Element: <source>

[this page | pdf | back links]

The HTML <source> element allows multiple media resources for media elements. It links together associated <video> and <audio>. It is new in HTML 5. The srcset attribute is required if the <source> element is used in a picture element, whilst the src attribute is required when the <source> element is used in an <audio> or <video> element.

 

The attributes it can take (other than HTML global attributes and HTML event attributes) include:

 

Attribute

Description

More

media

Specifies media / device linked document is optimised for

Here

sizes

Specifies image size(s)

Here

src

Required when URL of resource

Here

srcset

URL of image to use in different situations

Here

type

Type of element

Here

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods, and additional properties with the same name and meaning as the attributes of the underlying HTML element referred to above). The default style applicable to this element is shown here.

 


NAVIGATION LINKS
Contents | Prev | Next | HTML Elements


Desktop view | Switch to Mobile