search

Home  >  Q&A  >  body text

Can you add alt/aria-label directly in CSS?

<p>We are currently completing some accessibility checks on our website. One of the issues it found was that 2 icons on our mobile version required "recognizable text": </p> <p>On this page - https://sthelens.ac.uk/kcc-course-enquiry - the search icon and hamburger menu icon do not have alt text when viewing the mobile version. However, I can't seem to find where it is controlled. I found the CSS file that assigns the image. Can I add the alt text directly to the CSS, or do I need to find it somewhere else? </p> <p>Also, does anyone know why there seem to be 2 hamburger menus showing? </p> <p>If this helps, we are using Joomla. </p>
P粉106711425P粉106711425477 days ago669

reply all(1)I'll reply

  • P粉481035232

    P粉4810352322023-09-06 09:20:49

    The icons are both in your anchor tag, so you are using two icons in the menu. If these are images, then you should use "Alt". We can add tags through JS, but don't force the use of alt in the anchor. source

    const anchors = document.querySelectorAll('.mobile-controls a');
    anchors.forEach(anchor => {
        anchor.setAttribute('alt', 'Alternative text');
    });

    reply
    0
  • Cancelreply