YouTip LogoYouTip

Att Area Shape

# HTML <area> shape Attribute The `shape` attribute of the `` tag defines the geometric shape of an active, clickable region within an image map. By pairing the `shape` attribute with the `coords` attribute, you can specify the exact size, shape, and position of the clickable hotspots on an image. --- ## Browser Support The `shape` attribute is universally supported by all major modern web browsers: * Google Chrome * Mozilla Firefox * Microsoft Edge / Internet Explorer * Safari * Opera --- ## Syntax ```html ``` --- ## Attribute Values | Value | Description | `coords` Format & Requirements | | :--- | :--- | :--- | | **`default`** | Specifies the entire image area as the clickable region. | No coordinates are required. | | **`rect`** | Defines a rectangular region. | Requires 4 coordinates: `x1,y1,x2,y2`
β€’ `x1,y1`: Top-left corner
β€’ `x2,y2`: Bottom-right corner | | **`circle`** | Defines a circular region. | Requires 3 coordinates: `x,y,r`
β€’ `x,y`: Center of the circle
β€’ `r`: Radius of the circle | | **`poly`** | Defines a polygonal region (arbitrary shape). | Requires at least 6 coordinates (3 pairs): `x1,y1,x2,y2,...,xn,yn`
β€’ Each pair represents a vertex of the polygon. | --- ## Code Example Below is an example of an image map containing three clickable hotspots of different shapes (a rectangle and two circles): ```html Planets Sun Mercury Venus ``` --- ## Technical Considerations & Best Practices ### 1. Relationship with the `coords` Attribute The `shape` attribute must always be used in conjunction with the `coords` attribute (except when `shape="default"` is used). If the coordinates do not match the expected format of the chosen shape, the browser will not render the clickable hotspot correctly. ### 2. Responsive Images and Image Maps Standard HTML `` and `` coordinates are defined in absolute pixels relative to the original image dimensions. If the image is resized dynamically using CSS (e.g., `max-width: 100%`), the coordinates will not scale automatically. * **Solution:** To make image maps responsive, you can use modern CSS techniques (like SVG overlays) or lightweight JavaScript libraries such as `image-map-resizer` to dynamically recalculate coordinates on window resize. ### 3. Accessibility (a11y) Always include a descriptive `alt` attribute for each `` element. Screen readers rely on the `alt` text to describe the destination of the clickable hotspot to visually impaired users.
← Att Area TargetAtt Area Rel β†’