Web development

HTML picture Tag

Learn how to use the HTML picture element.

The HTML picture element gives the users more flexibility in defining image resources.

HTML picture Tag

The HTML picture element is used for art direction in responsive designs. Instead of having one image that is scaled on the viewport width, multiple images can be designed to nicely fill the browser viewport.

The HTML <picture> tag contains two tags: one or more <source> elements and one <img> tag.


Resize the browser window to load different images:

<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

  <source media="(min-width:650px)" srcset="">
  <source media="(min-width:465px)" srcset="">
  <img src="" alt="ghost" style="width:auto;">




Enjoy coding!

Read also:

HTML map and area tags

HTML time tag

HTML form tag