CKTIS / HTML
prvok HTML: area
Prázdny prvok oblasti definuje klikací región obrazovej mapy geometriou, cieľom a textovou alternatívou.
Verzia: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<map name="plan"><area href="details" alt="Details" shape="rect" coords="0,0,40,30"></map>area má význam iba v map s identifikátorom name, na ktorý img odkazuje cez usemap.
S prítomným href povinné alt pomenuje cieľ; bez href musí alt chýbať, pretože oblasť nie je odkazom.
shape prijíma default, rect, circle či poly; coords musí zodpovedať tvaru a pre default je zakázané.
Príklad číta kolekciu areas, skúša :any-link a sleduje prázdne childNodes obdĺžnikovej oblasti.
Príklady
<!doctype html>
<meta charset="utf-8">
<base href="https://example.test/maps/">
<map id="plan" name="plan">
<area id="room" href="room-1" alt="Room 1" shape="rect" coords="0,0,40,30">
<area id="rest" href="overview" alt="Other rooms" shape="default">
</map>
<img id="floor" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==" width="80" height="60" alt="Floor plan" usemap="#plan">
<output id="result"></output>
<script>
const plan = document.querySelector("#plan");
const room = document.querySelector("#room");
document.querySelector("#result").textContent = `areas=${plan.areas.length}; href=${room.href}; shape=${room.shape}; coords=${room.coords}; linked=${room.matches(":any-link")}; children=${room.childNodes.length}`;
</script>
Výsledok
areas=2; href=https://example.test/maps/room-1; shape=rect; coords=0,0,40,30; linked=true; children=0
Výsledok potvrdzuje model DOM a vyriešenú URL; nevykonáva test zásahu pixelu obrázka.