Image missing aria-label attribute

I am facing an issue with getting the aria-label to display on my image. Despite checking my code, I cannot figure out why it is not working. Any ideas on what might be missing?

Here is the code from my NextJS app:

The svg in my public folder.

<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="122.875px" height="28.489px" viewBox="0 0 122.875 28.489" enable-background="new 0 0 122.875 28.489" xml:space="preserve"><g><path fill-rule="evenodd" clip-rule="evenodd" d="M108.993,0c7.683-0.059,13.898,6.12,13.882,13.805 c-0.018,7.682-6.26,13.958-13.942,14.018c-31.683,0.222-63.368,0.444-95.051,0.666C6.2,28.549-0.016,22.369,0,14.685 C0.018,7.002,6.261,0.726,13.943,0.667C45.626,0.445,77.311...

I then import the svg from my data folder.

import Minus from "public/minus-icon.svg";

export list = [
  { name: "One two and three and four and five till six and stop", icon: Minus }
]

Next, in my component:

<Image
                  priority
                  src={item.icon}
                  height={20}
                  width={20}
                  alt={item.name}
                  aria-labelledby={item.name}
                />
                <title id={item.name}>{item.name}</title>

Although everything seems to be set up correctly (excluding unrelated code like

import Image from "next/image";
), the aria-label is not appearing in the front-end when hovering over the image. If I directly use the svg inline, the aria-label shows properly. Any suggestions or assistance would be greatly appreciated. Thank you. P.S. If I just use the svg directly, inline code I mean, then with the above aria-label code all works and I can see front-end the label upon hover.

Answer №1

ARIA tags do not affect the front end of a website. Their main purpose is for accessibility reasons, (Learn more here: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA). If you need text to display when hovering over an image, consider using the title attribute on the image element.

For example:

<Image
    priority
    src={item.icon}
    height={20}
    width={20}
    alt={item.name}
    title={item.name}
 />

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Merging ng-if conditions

I would like to find a way for my two ng-if conditions to work together instead of separately. I want to display only the last one if both are true. Currently, this is how my code looks: <div> <img ng-src="{{img(myColor)}}" ng-if="myColor" ...

Why are cloned jQuery elements triggering events on the parent <div> and not the child <div>?

Currently, I am working on a tool that includes dynamic input fields for user input. To create different sections, I have cloned some divs from the code successfully. However, I am facing an issue where the events attached to the parent div are triggered e ...

What is the right height and width to use in CSS?

I find it challenging to decide when to use rem, em, px, or % in web design. Although I know the definitions of each unit, I struggle with knowing the appropriate situations to utilize them. What guidelines should I follow to determine which one to use? ...

How can I trigger a function or automate code execution in Angular?

I have some code within a function that is crucial for initializing other variables. The issue I am facing is that this function does not execute unless it is called through another tag in the HTML. Is there a method to automatically initialize this func ...

Printing a modified div element that was created using jQuery on an ASP.NET MVC webpage after the initial page has finished loading

In my view, there is a div that holds multiple tables generated based on the model. Each row in these tables contains fields that can be edited using TextBoxFor. Through jQuery, rows can be moved between tables and new tables can be created dynamically wit ...

CSS techniques for aligning content

I am currently working on designing a website template, and I have encountered an issue with positioning three individual columns that contain blocks of content. My objective is to have the first block of content in each column start at the top of their re ...

Client request: receive a daily update detailing the differences between two databases

Today, a customer requested that I provide daily reports on the changes between two tables in our database. I am currently contemplating the most efficient and intelligent way to fulfill this request. Should I create a SQL procedure? Or perhaps an HTML p ...

Contrasting gatsby-theme-material-ui and gatsby-plugin-material-ui

I'm in the process of creating a website using Gatsby, and I'd like to incorporate Material UI, but I'm unsure about which plugin I should use. Here are my questions: What is the difference between these two options, and how can I integra ...

Incorporating YouTube videos into Internet Explorer

On my webpage, I have included a YouTube video: <div class="col-md-8"> <iframe id="theframe" width="400" height="325" src="http://www.youtube.com/embed/MYYOUTUBECLIP" frameborder="0" allowfullscreen class=""></iframe> While this works p ...

Confirm the data in each field of a form individually

I am facing an issue with a form that contains 7 fields. When I submit the form to the "register.php" page, it processes each field one by one and outputs the result as a whole. However, I need to validate the data using ajax, collect the output one by one ...

Code for Rotating the Wheel - MINUS javascript

Exploring the possibility of creating a spin the wheel effect like this using only HTML and CSS, no Javascript involved Seeking references or examples to determine feasibility. ...

What is the best way to store an audio Blob in the repository file system?

Currently, I have set up a system to record user audio through the device's microphone and can successfully download it on the same device. However, my goal now is to store this audio in my database by making an API call. How can I efficiently send th ...

Unable to retrieve property from NextRequest

Currently, I am attempting to utilize MiddleWare in conjunction with Next.js's Middleware and JWT. Upon logging cookies and the typeof cookies variable, this is what I see on my console: { token: 'token='myToken'; Path=/' } obj ...

Conceal the popper for one field while revealing the popper for another field

In my current project, I have implemented two text fields positioned next to each other with button adornments at the end. These buttons are used to toggle the visibility of a popper associated with each text field. Additionally, each popper is equipped wi ...

What is the best way to conceal a canvas or another item?

Within my main canvas, there are three smaller canvases and a text element. <canvas id="Background" width="350" height="300" style="border:6px solid black; position: absolute; left: 10px; top: 10px;"> </canvas> <canvas id="Canvas1" width ...

Having trouble getting the React Router Dom Link function to function properly

Within my React component, PostItem, I have implemented a link to the edit post page. Surprisingly, this particular link does not work while all other links in different components are functioning properly. Although the page is rendered successfully with ...

I want to display a div above an image when hovering over it

.vpbutton {padding:4px;background-color:#EFEFEF;} .userbox img{padding:8px;background-color:#EFEFEF;} .userbox img:hover{opacity:.2;} <div class="userbox"> <img src='img.png' style='height:120px;width:120px;border:1p ...

Create your own unique Semantic UI themes using the Semantic UI theme builder, complete with support for Font Awesome classnames and the ability to preview them with the

My admiration for Semantic UI and Semantic UI React knows no bounds. Not only are they phenomenal libraries, but their documentation is truly a work of art. Yet, crafting and keeping up with themes for these components can be quite the challenge. The task ...

Troubleshooting the Create Order Issue: Integrating PayPal Checkout with Smart Payment Buttons using React and Redux

Every time I attempt to process a payment, I encounter a 422 error: Unprocessable entity. The issue arises when I try to dynamically capture the purchased item details received from the redux store. I tried following this example (duplicate): PayPal Check ...

Unable to select dropdown button in Python while using Selenium

My goal is to click on the "Project" element in order to display a dropdown list (as shown in the image below). When using the selenium library in Python, I encountered the following error: could not be scrolled into view This error was triggered by code ...