47 key={`${term}-${trackIndex}`}
48 className="track"
49 href={track.href}>
50 <img51 className="cover"52 src={track.image ?? null}53 width="48"54 height="48" />55 <div className="details">
56 <Text
57 className="name"
75 paddingLeft: 4,
76 paddingTop: 8,
77 }}>
78 <img 79 id="cover" 80 height="48" 81 src={ track.image ?? null } 82 width="48" /> 83
84 <div
85 style={{
51 key={`chess-game-${ gameIndex }=row-${ rowIndex }-col-${ colIndex }`}
52 className={`col ${(rowIndex + colIndex) % 2 === (game.isWhite ? 0 : 1) ? 'light' : ''} ${game.noGame ? 'empty' : ''}`}>
53 {col &&
54 <img src={ pieceImages[`${col === col.toUpperCase() ? 'white' : 'black' }-${ col.toLowerCase() }`]}></img>55 }
56 </div>
57 ))}
The alternative text attached to any content is a critical component of accessibility for screen reader users as it helps them understand the content's purpose on the page. By default, this rule checks for alternative text on the following elements: <img>
, <area>
, <input type="image">
, and <object>
.
<img>
: An <img>
element must have the alt
property set with meaningful text or as an empty string to indicate that it is an image for decoration.
For images that are being used as icons for a button or control, the alt
property should be set to an empty string (alt=""
).
<button>
<img src="icon.png" alt="" />
Save
</button>
The content of an alt
attribute is used to determine accessibility of an element.
Whereas the content of the label
is use to show a text content of an element.
For this reason, adding a label
to an icon can create confusion with the already present appropriate text content.
<object>
: Add alternative text to all embedded <object>
elements using either inner text, setting the title
prop, or using the aria-label
or aria-labelledby
props.
<input type="image">
: All <input type="image">
elements must have a non-empty alt
prop set with a meaningful description of the image or have the aria-label
or aria-labelledby
props set.
<area>
: All clickable <area>
elements within an image map have an alt
, aria-label
or aria-labelledby
prop that describes the purpose of the link.
function Foo(props) {
return <img {...props} />
}
function Foo({ alt, ...props}) {
return <img alt={alt} {...props} />
}
// OR
function Foo(props) {
const {
alt,
...otherProps
} = props;
return <img alt={alt} {...otherProps} />
}