diff options
Diffstat (limited to 'files/it/web/html/element/img/index.html')
-rw-r--r-- | files/it/web/html/element/img/index.html | 422 |
1 files changed, 0 insertions, 422 deletions
diff --git a/files/it/web/html/element/img/index.html b/files/it/web/html/element/img/index.html deleted file mode 100644 index f9d0d4370d..0000000000 --- a/files/it/web/html/element/img/index.html +++ /dev/null @@ -1,422 +0,0 @@ ---- -title: '<img>: The Image Embed element' -slug: Web/HTML/Element/img -translation_of: Web/HTML/Element/img ---- -<div>{{HTMLRef}}</div> - -<p><span class="seoSummary">L'<strong>elemento</strong> <strong>HTML <code><img></code></strong> inserisce un'immagine nel documento.</span></p> - -<div>{{EmbedInteractiveExample("pages/tabbed/img.html", "tabbed-standard")}}</div> - -<div class="hidden">I sorgenti di questo esempio interattivo sono presenti in un repository GitHub. Se vuoi contribuire al progetto degli esempi interattivi, clona <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples </a>e inviaci una pull request.</div> - -<p>L'esempio qui sopra mostra l'uso dell'elemento <code><img></code>:</p> - -<ul> - <li>L'attributo <code>src</code> è <strong>obbligatorio</strong> e contiene il percorso dell'immagine che si desidera inserire.</li> - <li>L'attributo <code>alt</code> contiene una descrizione testuale dell'immagine, che non è obbligatoria, ma è <strong>incredibilmente utile</strong> per l'accessibilità — gli screen reader leggono questa descrizione ai loro utenti, per indicare cosa contiene l'immagine. Il testo dell'Alt viene anche mostrato in pagina se per qualche motivo l'immagine non può essere caricata: per esempio, errori di rete, blocco dei contenuti, o link errato.</li> -</ul> - -<p>There are many other attributes to achieve various purposes:</p> - -<ul> - <li><a href="/en-US/docs/Web/HTTP/Headers/Referrer-Policy">Referrer</a>/{{glossary("CORS")}} control for security and privacy: see {{htmlattrxref("crossorigin", "img")}} and {{htmlattrxref("referrerpolicy", "img")}}.</li> - <li>Use both {{htmlattrxref("width", "img")}} and {{htmlattrxref("height", "img")}} to set the intrinsic size of the image, allowing it to take up space before it loads, to mitigate content layout shifts.</li> - <li>Responsive image hints with {{htmlattrxref("sizes", "img")}} and {{htmlattrxref("srcset", "img")}} (see also the {{htmlelement("picture")}} element and our <a href="/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images">Responsive images</a> tutorial).</li> -</ul> - -<h2 id="Supported_image_formats">Supported image formats</h2> - -<p>The HTML standard doesn't list what image formats to support, so each {{glossary("user agent")}} supports different formats. A complete <a href="/en-US/docs/Web/Media/Formats/Image_types">guide to image formats supported by web browsers</a> is available. Below is a list of the image formats that are most commonly used on the web, as well as some older formats that should no longer be used, despite existing content possibly still using them.</p> - -<p>{{page("/en-US/docs/Web/Media/Formats/Image_types", "table-of-image-file-types")}}</p> - -<h2 id="Image_loading_errors">Image loading errors</h2> - -<p>If an error occurs while loading or rendering an image, and an {{htmlattrxref("onerror")}} event handler has been set on the {{event("error")}} event, that event handler will get called. This can happen in a number of situations, including:</p> - -<ul> - <li>The <code>src</code> attribute is empty (<code>""</code>) or <code>null</code>.</li> - <li>The <code>src</code> {{glossary("URL")}} is the same as the URL of the page the user is currently on.</li> - <li>The image is corrupted in some way that prevents it from being loaded.</li> - <li>The image's metadata is corrupted in such a way that it's impossible to retrieve its dimensions, and no dimensions were specified in the <code><img></code> element's attributes.</li> - <li>The image is in a format not supported by the {{Glossary("user agent")}}.</li> -</ul> - -<h2 id="Attributes">Attributes</h2> - -<p>This element includes the <a href="/en-US/docs/HTML/Global_attributes">global attributes</a>.</p> - -<dl> - <dt>{{htmlattrdef("alt")}}</dt> - <dd>Defines an alternative text description of the image. - <div class="note"> - <p><strong>Note:</strong> Browsers do not always display images. There are a number of situations in which a browser might not display images, such as:</p> - - <ul> - <li>Non-visual browsers (such as those used by people with visual impairments)</li> - <li>The user chooses not to display images (saving bandwidth, privacy reasons)</li> - <li>The image is invalid or an <a href="#Supported_image_formats">unsupported type</a></li> - </ul> - - <p>In these cases, the browser may replace the image with the text in the element's <code>alt</code> attribute. For these reasons and others, provide a useful value for <code>alt</code> whenever possible.</p> - </div> - - <p>Omitting <code>alt</code> altogether indicates that the image is a key part of the content and no textual equivalent is available. Setting this attribute to an empty string (<code>alt=""</code>) indicates that this image is <em>not</em> a key part of the content (it’s decoration or a tracking pixel), and that non-visual browsers may omit it from {{glossary("Rendering engine", "rendering")}}. Visual browsers will also hide the broken image icon if the <code>alt</code> is empty and the image failed to display.</p> - - <p>This attribute is also used when copying and pasting the image to text, or saving a linked image to a bookmark.</p> - </dd> - <dt>{{htmlattrdef("crossorigin")}}</dt> - <dd> - <p>Indicates if the fetching of the image must be done using a {{glossary("CORS")}} request. Image data from a <a href="/en-US/docs/CORS_Enabled_Image">CORS-enabled image</a> returned from a CORS request can be reused in the {{HTMLElement("canvas")}} element without being marked "<a href="/en-US/docs/Web/HTML/CORS_enabled_image#What_is_a_tainted_canvas">tainted</a>".</p> - - <p>If the <code>crossorigin</code> attribute is <em>not</em> specified, then a non-CORS request is sent (without the {{httpheader("Origin")}} request header), and the browser marks the image as tainted and restricts access to its image data, preventing its usage in {{HTMLElement("canvas")}} elements.</p> - - <p>If the <code>crossorigin</code> attribute <em>is</em> specified, then a CORS request is sent (with the {{httpheader("Origin")}} request header); but if the server does not opt into allowing cross-origin access to the image data by the origin site (by not sending any {{httpheader("Access-Control-Allow-Origin")}} response header, or by not including the site's origin in any {{httpheader("Access-Control-Allow-Origin")}} response header it does send), then the browser marks the image as tainted and restricts access to its image data, preventing its usage in {{HTMLElement("canvas")}} elements.</p> - </dd> - <dd></dd> - <dd> - <p>Allowed values:</p> - - <dl> - <dt><code>anonymous</code></dt> - <dd>A CORS request is sent with credentials omitted (that is, no {{glossary("cookie", "cookies")}}, <a class="external" href="https://tools.ietf.org/html/rfc5280">X.509 certificates</a>, or {{httpheader("Authorization")}} request header).</dd> - <dt><code>use-credentials</code></dt> - <dd>The CORS request is sent with any credentials included (that is, cookies, X.509 certificates, and the <code>Authorization</code> request header). If the server does not opt into sharing credentials with the origin site (by sending back the <code>Access-Control-Allow-Credentials: true</code> response header), then the browser marks the image as tainted and restricts access to its image data.</dd> - </dl> - - <p>If the attribute has an invalid value, browsers handle it as if the <code>anonymous</code> value was used. See <a href="/en-US/docs/HTML/CORS_settings_attributes">CORS settings attributes</a> for additional information.</p> - </dd> - <dt>{{htmlattrdef("decoding")}}</dt> - <dd> - <p>Provides an image decoding hint to the browser. Allowed values:</p> - </dd> - <dd> - <dl> - <dt><code>sync</code></dt> - <dd>Decode the image synchronously, for atomic presentation with other content.</dd> - <dt><code>async</code></dt> - <dd>Decode the image asynchronously, to reduce delay in presenting other content.</dd> - <dt><code>auto</code></dt> - <dd>Default: no preference for the decoding mode. The browser decides what is best for the user.</dd> - </dl> - </dd> - <dt>{{htmlattrdef("height")}}</dt> - <dd>The intrinsic height of the image, in pixels. Must be an integer without a unit.</dd> - <dt>{{htmlattrdef("intrinsicsize")}} {{deprecated_inline}}</dt> - <dd>This attribute tells the browser to ignore the actual {{glossary("intrinsic size")}} of the image and pretend it’s the size specified in the attribute. Specifically, the image would raster at these dimensions and <code>naturalWidth</code>/<code>naturalHeight</code> on images would return the values specified in this attribute. <a class="external" href="https://github.com/ojanvafai/intrinsicsize-attribute">Explainer</a>, <a class="external" href="https://googlechrome.github.io/samples/intrinsic-size/index.html">examples</a></dd> - <dt>{{htmlattrdef("ismap")}}</dt> - <dd>This Boolean attribute indicates that the image is part of a <a href="https://en.wikipedia.org/wiki/Image_map#Server-side">server-side map</a>. If so, the coordinates where the user clicked on the image are sent to the server. - <div class="note"> - <p><strong>Note:</strong> This attribute is allowed only if the <code><img></code> element is a descendant of an {{htmlelement("a")}} element with a valid {{htmlattrxref("href","a")}} attribute. This gives users without pointing devices a fallback destination.</p> - </div> - </dd> - <dt>{{htmlattrdef("loading")}}</dt> - <dd>Indicates how the browser should load the image: - <ul> - <li><code>eager</code>: Loads the image immediately, regardless of whether or not the image is currently within the visible viewport (this is the default value).</li> - <li><code>lazy</code>: Defers loading the image until it reaches a calculated distance from the viewport, as defined by the browser. The intent is to avoid the network and storage bandwidth needed to handle the image until it's reasonably certain that it will be needed. This generally improves the performance of the content in most typical use cases. - <div class="note"><strong>Note:</strong> Loading is only deferred when JavaScript is enabled. This is an anti-tracking measure, because if a user agent supported lazy loading when scripting is disabled, it would still be possible for a site to track a user's approximate scroll position throughout a session, by strategically placing images in a page's markup such that a server can track how many images are requested and when.</div> - </li> - </ul> - </dd> - <dt>{{htmlattrdef("referrerpolicy")}} {{experimental_inline}}</dt> - <dd>A string indicating which referrer to use when fetching the resource: - <ul> - <li><code>no-referrer</code>: The {{httpheader("Referer")}} header will not be sent.</li> - <li><code>no-referrer-when-downgrade</code>: No <code>Referer</code> header is sent when navigating to an origin without {{glossary("HTTPS")}}. This is the default if no policy is otherwise specified.</li> - <li><code>origin</code>: The <code>Referer</code> header will include the page's origin ({{glossary("scheme")}}, {{glossary("host")}}, and {{glossary("port")}}).</li> - <li><code>origin-when-cross-origin</code>: Navigating to other origins will limit the included referral data to the scheme, host, and port, while navigating from the same origin will include the full path and query string.</li> - <li><code>unsafe-url</code>: The <code>Referer</code> header will always include the origin, path and query string, but not the fragment, password, or username. <strong>This is unsafe</strong> because it can leak information from TLS-protected resources to insecure origins.</li> - </ul> - </dd> - <dt>{{htmlattrdef("sizes")}}</dt> - <dd>One or more strings separated by commas, indicating a set of source sizes. Each source size consists of: - <ol> - <li>A <a href="/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#Syntax">media condition</a>. This must be omitted for the last item in the list.</li> - <li>A source size value.</li> - </ol> - - <p>Media Conditions describe properties of the <em>viewport</em>, not of the <em>image</em>. For example, <code>(max-height: 500px) 1000px</code> proposes to use a source of 1000px width, if the <em>viewport </em>is not higher than 500px.</p> - - <p>Source size values specify the intended display size of the image. {{glossary("User agent", "User agents")}} use the current source size to select one of the sources supplied by the <code>srcset</code> attribute, when those sources are described using width (<code>w</code>) descriptors. The selected source size affects the {{glossary("intrinsic size")}} of the image (the image’s display size if no {{glossary("CSS")}} styling is applied). If the <code>srcset</code> attribute is absent, or contains no values with a width descriptor, then the <code>sizes</code> attribute has no effect.</p> - </dd> - <dt>{{htmlattrdef("src")}}</dt> - <dd>The image {{glossary("URL")}}. Mandatory for the <code><img></code> element. On {{glossary("Browser", "browsers")}} supporting <code>srcset</code>, <code>src</code> is treated like a candidate image with a pixel density descriptor <code>1x</code>, unless an image with this pixel density descriptor is already defined in <code>srcset</code>, or unless <code>srcset</code> contains <code>w</code> descriptors.</dd> - <dt>{{htmlattrdef("srcset")}}</dt> - <dd>One or more strings separated by commas, indicating possible image sources for the {{glossary("user agent")}} to use. Each string is composed of: - <ol> - <li>A {{glossary("URL")}} to an image</li> - <li>Optionally, whitespace followed by one of: - <ul> - <li>A width descriptor (a positive integer directly followed by <code>w</code>). The width descriptor is divided by the source size given in the <code>sizes</code> attribute to calculate the effective pixel density.</li> - <li>A pixel density descriptor (a positive floating point number directly followed by <code>x</code>).</li> - </ul> - </li> - </ol> - - <p>If no descriptor is specified, the source is assigned the default descriptor of <code>1x</code>.</p> - - <p>It is incorrect to mix width descriptors and pixel density descriptors in the same <code>srcset</code> attribute. Duplicate descriptors (for instance, two sources in the same <code>srcset</code> which are both described with <code>2x</code>) are also invalid.</p> - - <p>The user agent selects any of the available sources at its discretion. This provides them with significant leeway to tailor their selection based on things like user preferences or {{glossary("bandwidth")}} conditions. See our <a href="/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images">Responsive images</a> tutorial for an example.</p> - </dd> - <dt>{{htmlattrdef("width")}}</dt> - <dd>The intrinsic width of the image in pixels. Must be an integer without a unit.</dd> - <dt>{{htmlattrdef("usemap")}}</dt> - <dd>The partial {{glossary("URL")}} (starting with <code>#</code>) of an <a href="/en-US/docs/HTML/Element/map">image map</a> associated with the element. - <div class="note"> - <p><strong>Note: </strong>You cannot use this attribute if the <code><img></code> element is inside an {{htmlelement("a")}} or {{HTMLElement("button")}} element.</p> - </div> - </dd> -</dl> - -<h3 id="Deprecated_attributes">Deprecated attributes</h3> - -<dl> - <dt>{{htmlattrdef("align")}} {{Obsolete_Inline}}</dt> - <dd>Aligns the image with its surrounding context. Use the {{cssxref('float')}} and/or {{cssxref('vertical-align')}} {{glossary("CSS")}} properties instead of this attribute. Allowed values:</dd> - <dd> - <dl> - <dt><code>top</code></dt> - <dd>Equivalent to <code style="white-space: nowrap;">vertical-align: top</code> or <code style="white-space: nowrap;">vertical-align: text-top</code></dd> - <dt><code>middle</code></dt> - <dd>Equivalent to <code style="white-space: nowrap;">vertical-align: -moz-middle-with-baseline</code></dd> - <dt><code>bottom</code></dt> - <dd>The default, equivalent to <code style="white-space: nowrap;">vertical-align: unset</code> or <code style="white-space: nowrap;">vertical-align: initial</code></dd> - <dt><code>left</code></dt> - <dd>Equivalent to <code style="white-space: nowrap;">float: left</code></dd> - <dt><code>right</code></dt> - <dd>Equivalent to <code style="white-space: nowrap;">float: right</code></dd> - </dl> - </dd> - <dt>{{htmlattrdef("border")}} {{Obsolete_Inline}}</dt> - <dd>The width of a border around the image. Use the {{cssxref('border')}} {{glossary("CSS")}} property instead.</dd> - <dt>{{htmlattrdef("hspace")}} {{Obsolete_Inline}}</dt> - <dd>The number of pixels of white space on the left and right of the image. Use the {{cssxref('margin')}} CSS property instead.</dd> - <dt>{{htmlattrdef("longdesc")}} {{Obsolete_Inline}}</dt> - <dd>A link to a more detailed description of the image. Possible values are a {{glossary("URL")}} or an element {{htmlattrxref("id")}}. - <div class="note"> - <p><strong>Note:</strong> This attribute is mentioned in the latest {{glossary("W3C")}} version, <a class="external" href="https://www.w3.org/TR/html52/obsolete.html#element-attrdef-img-longdesc">HTML 5.2</a>, but has been removed from the {{glossary("WHATWG")}}’s <a class="external" href="https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element">HTML Living Standard</a>. It has an uncertain future; authors should use a {{glossary("WAI")}}-{{glossary("ARIA")}} alternative such as <a class="external" href="https://www.w3.org/TR/wai-aria-1.1/#aria-describedby"><code>aria-describedby</code></a> or <a class="external" href="https://www.w3.org/TR/wai-aria-1.1/#aria-details"><code>aria-details</code></a>.</p> - </div> - </dd> - <dt>{{htmlattrdef("name")}} {{Obsolete_Inline}}</dt> - <dd>A name for the element. Use the {{htmlattrxref("id")}} attribute instead.</dd> - <dt>{{htmlattrdef("vspace")}} {{Obsolete_Inline}}</dt> - <dd>The number of pixels of white space above and below the image. Use the {{cssxref('margin')}} CSS property instead.</dd> -</dl> - -<h2 id="Styling_with_CSS">Styling with CSS</h2> - -<p><code><img></code> is a <a href="/en-US/docs/Web/CSS/Replaced_element">replaced element</a>; it has a {{cssxref("display")}} value of <code>inline</code> by default, but its default dimensions are defined by the embedded image's intrinsic values, like it were <code>inline-block</code>. You can set properties like {{cssxref("border")}}/{{cssxref("border-radius")}}, {{cssxref("padding")}}/{{cssxref("margin")}}, {{cssxref("width")}}, {{cssxref("height")}}, etc. on an image.</p> - -<p><code><img></code> has no baseline, so when images are used in an inline formatting context with {{cssxref("vertical-align")}}<code>: baseline</code>, the bottom of the image will be placed on the text baseline.</p> - -<p>You can use the {{cssxref("object-position")}} property to position the image within the element's box, and the {{cssxref("object-fit")}} property to adjust the sizing of the image within the box (for example, whether the image should fit the box or fill it even if clipping is required).</p> - -<p>Depending on its type, an image may have an intrinsic width and height. For some image types, however, intrinsic dimensions are unnecessary. {{glossary("SVG")}} images, for instance, have no intrinsic dimensions if their root {{SVGElement("svg")}} element doesn't have a <code>width</code> or <code>height</code> set on it.</p> - -<h2 id="Examples">Examples</h2> - -<h3 id="Alternative_text">Alternative text</h3> - -<p>The following example embeds an image into the page and includes alternative text for accessibility.</p> - -<pre class="brush: html notranslate"><img src="https://developer.mozilla.org/static/img/favicon144.png" - alt="MDN logo"> -</pre> - -<p>{{ EmbedLiveSample('Alternative_text', '100%', '160') }}</p> - -<h3 id="Image_link">Image link</h3> - -<p>This example builds upon the previous one, showing how to turn the image into a link. To do so, nest the <code><img></code> tag inside the {{HTMLElement("a")}}. You should made the alternative text describe the resource the link is pointing to, as if you were using a text link instead.</p> - -<pre class="brush: html notranslate"><a href="https://developer.mozilla.org"> - <img src="https://developer.mozilla.org/static/img/favicon144.png" - alt="Visit the MDN site"> -</a></pre> - -<p>{{ EmbedLiveSample('Image_link', '100%', '160') }}</p> - -<h3 id="Using_the_srcset_attribute">Using the srcset attribute</h3> - -<p>In this example we include a <code>srcset</code> attribute with a reference to a high-resolution version of the logo; this will be loaded instead of the <code>src</code> image on high-resolution devices. The image referenced in the <code>src</code> attribute is counted as a <code>1x</code> candidate in {{glossary("User agent", "user agents")}} that support <code>srcset</code>.</p> - -<pre class="brush: html notranslate"> <img src="https://developer.mozilla.org/static/img/favicon72.png" - alt="MDN logo" - srcset="https://developer.mozilla.org/static/img/favicon144.png 2x"></pre> - -<p>{{EmbedLiveSample("Using_the_srcset_attribute", "100%", "160")}}</p> - -<h3 id="Using_the_srcset_and_sizes_attributes">Using the srcset and sizes attributes</h3> - -<p>The <code>src</code> attribute is ignored in {{glossary("User agent", "user agents")}} that support <code>srcset</code> when <code>w</code> descriptors are included. When the <code>(max-width: 600px)</code> media condition matches, the 200 pixel-wide image will load (it is the one that matches <code>200px</code> most closely), otherwise the other image will load.</p> - -<pre class="brush: html notranslate"> <img src="/files/16864/clock-demo-200px.png" - alt="Clock" - srcset="/files/16864/clock-demo-200px.png 200w, - /files/16797/clock-demo-400px.png 400w" - sizes="(max-width: 600px) 200px, 50vw"></pre> - -<p>{{EmbedLiveSample("Using_the_srcset_and_sizes_attributes", "100%", 350)}}</p> - -<div class="blockIndicator note"> -<p>To see the resizing in action, <a href="https://mdn.mozillademos.org/en-US/docs/Web/HTML/Element/img$samples/Using_the_srcset_and_sizes_attributes">view the example on a separate page</a>, so you can actually resize the content area.</p> -</div> - -<h2 id="Security_and_privacy_concerns">Security and privacy concerns</h2> - -<p>Although <code><img></code> elements have innocent uses, they can have undesirable consequences for user security and privacy. See <a href="/en-US/docs/Web/Security/Referer_header:_privacy_and_security_concerns">Referer header: privacy and security concerns</a> for more information and mitigations.</p> - -<h2 id="Accessibility_concerns">Accessibility concerns</h2> - -<h3 id="Authoring_meaningful_alternate_descriptions">Authoring meaningful alternate descriptions</h3> - -<p>An <code>alt</code> attribute's value should clearly and concisely describe the image's content. It should not describe the presence of the image itself or the file name of the image. If the <code>alt</code> attribute is purposefully left off because the image has no textual equivalent, consider alternate methods to present what the image is trying to communicate.</p> - -<h4 id="Dont">Don't</h4> - -<pre class="brush: html example-bad notranslate"><img alt="image" src="penguin.jpg"> -</pre> - -<h4 id="Do">Do</h4> - -<pre class="brush: html example-good notranslate"><img alt="A Rockhopper Penguin standing on a beach." src="penguin.jpg"> -</pre> - -<p>When an <code>alt</code> attribute is not present on an image, some screen readers may announce the image's file name instead. This can be a confusing experience if the file name isn't representative of the image's contents.</p> - -<ul> - <li><a class="external" href="https://www.w3.org/WAI/tutorials/images/decision-tree/">An alt Decision Tree • Images • WAI Web Accessibility Tutorials</a></li> - <li><a class="external" href="https://axesslab.com/alt-texts/">Alt-texts: The Ultimate Guide — Axess Lab</a></li> - <li><a class="external" href="https://www.deque.com/blog/great-alt-text-introduction/">How to Design Great Alt Text: An Introduction | Deque</a></li> - <li><a href="/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable#Guideline_1.1_—_Providing_text_alternatives_for_non-text_content">MDN Understanding WCAG, Guideline 1.1 explanations</a></li> - <li><a class="external" href="https://www.w3.org/TR/UNDERSTANDING-WCAG20/text-equiv-all.html">Understanding Success Criterion 1.1.1 | W3C Understanding WCAG 2.0</a></li> -</ul> - -<h3 id="The_title_attribute">The title attribute</h3> - -<p>The {{htmlattrxref("title")}} attribute is not an acceptable substitute for the <code>alt</code> attribute. Additionally, avoid duplicating the <code>alt</code> attribute's value in a <code>title</code> attribute declared on the same image. Doing so may cause some screen readers to announce the description twice, creating a confusing experience.</p> - -<p>The <code>title</code> attribute should also not be used as supplemental captioning information to accompany an image's <code>alt</code> description. If an image needs a caption, use the <code><a href="/en-US/docs/Web/HTML/Element/figure">figure</a></code> and <code><a href="/en-US/docs/Web/HTML/Element/figcaption">figcaption</a></code> elements.</p> - -<p>The value of the <code>title</code> attribute is usually presented to the user as a tooltip, which appears shortly after the cursor stops moving over the image. While this <em>can</em> provide additional information to the user, you should not assume that the user will ever see it: the user may only have keyboard or touchscreen. If you have information that's particularly important or valuable for the user, present it inline using one of the methods mentioned above instead of using <code>title</code>.</p> - -<ul> - <li><a class="external" href="https://developer.paciellogroup.com/blog/2013/01/using-the-html-title-attribute-updated/">Using the HTML title attribute – updated | The Paciello Group</a></li> -</ul> - -<h2 id="Technical_summary">Technical summary</h2> - -<table class="properties"> - <tbody> - <tr> - <th scope="row"><a href="/en-US/docs/Web/Guide/HTML/Content_categories">Content categories</a></th> - <td><a href="/en-US/docs/Web/Guide/HTML/Content_categories#Flow_content">Flow content</a>, <a href="/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content">phrasing content</a>, <a href="/en-US/docs/Web/Guide/HTML/Content_categories#Embedded_content">embedded content</a>, <a href="/en-US/docs/Web/Guide/HTML/Content_categories#Palpable_content">palpable content</a>. If the element has a <code>usemap</code> attribute, it also is a part of the interactive content category.</td> - </tr> - <tr> - <th scope="row">Permitted content</th> - <td>None, it is an {{Glossary("empty element")}}.</td> - </tr> - <tr> - <th scope="row">Tag omission</th> - <td>Must have a start tag and must not have an end tag.</td> - </tr> - <tr> - <th scope="row">Permitted parents</th> - <td>Any element that accepts embedded content.</td> - </tr> - <tr> - <th scope="row">Implicit ARIA role</th> - <td> - <ul> - <li>with non-empty <code>alt</code> attribute or no <code>alt</code> attribute: <code><a href="/en-US/docs/Web/Accessibility/ARIA/Roles/Role_Img">img</a></code></li> - <li>with empty <code>alt</code> attribute: <a href="https://www.w3.org/TR/html-aria/#dfn-no-corresponding-role">no corresponding role</a></li> - </ul> - </td> - </tr> - <tr> - <th scope="row">Permitted ARIA roles</th> - <td> - <ul> - <li>with non-empty <code>alt</code> attribute: - <ul> - <li><code><a href="/en-US/docs/Web/Accessibility/ARIA/Roles/button_role">button</a></code></li> - <li><code><a href="/en-US/docs/Web/Accessibility/ARIA/Roles/checkbox_role">checkbox</a></code></li> - <li>{{ARIARole("link")}}</li> - <li>{{ARIARole("menuitem")}}</li> - <li>{{ARIARole("menuitemcheckbox")}}</li> - <li>{{ARIARole("menuitemradio")}}</li> - <li>{{ARIARole("option")}}</li> - <li>{{ARIARole("progressbar")}}</li> - <li>{{ARIARole("scrollbar")}}</li> - <li>{{ARIARole("separator")}}</li> - <li>{{ARIARole("slider")}}</li> - <li><code><a href="/en-US/docs/Web/Accessibility/ARIA/Roles/Switch_role">switch</a></code></li> - <li><code><a href="/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role">tab</a></code></li> - <li>{{ARIARole("treeitem")}}</li> - </ul> - </li> - <li>with empty <code>alt</code> attribute, {{ARIARole("none")}} or {{ARIARole("presentation")}}</li> - <li>with no <code>alt</code> attribute, no <code>role</code> permitted</li> - </ul> - </td> - </tr> - <tr> - <th scope="row">DOM interface</th> - <td>{{domxref("HTMLImageElement")}}</td> - </tr> - </tbody> -</table> - -<h2 id="Specifications">Specifications</h2> - -<table class="standard-table"> - <thead> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('Referrer Policy', '#referrer-policy-delivery-referrer-attribute', 'referrer attribute')}}</td> - <td>{{Spec2('Referrer Policy')}}</td> - <td>Added the <code>referrerpolicy</code> attribute.</td> - </tr> - <tr> - <td>{{SpecName('HTML WHATWG', 'embedded-content.html#the-img-element', '<img>')}}</td> - <td>{{Spec2('HTML WHATWG')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('HTML5 W3C', 'semantics-embedded-content.html#the-img-element', '<img>')}}</td> - <td>{{Spec2('HTML5 W3C')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('HTML4.01', 'struct/objects.html#h-13.2', '<img>')}}</td> - <td>{{Spec2('HTML4.01')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("html.elements.img")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><a href="/en-US/docs/Learn/HTML/Multimedia_and_embedding/Images_in_HTML">Images in HTML</a></li> - <li><a href="/en-US/docs/Web/Media/Formats/Image_types">Image file type and format guide</a></li> - <li><a href="/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images">Responsive images</a></li> - <li>{{HTMLElement("picture")}}, {{HTMLElement("object")}} and {{HTMLElement("embed")}} elements</li> - <li>Other image-related CSS properties: {{cssxref("object-fit")}}, {{cssxref("object-position")}}, {{cssxref("image-orientation")}}, {{cssxref("image-rendering")}}, and {{cssxref("image-resolution")}}.</li> -</ul> |