Re: Alt text on HTML tables

Subject: Re: Alt text on HTML tables
From: "Sweet, Gregory P (HEALTH)" <gregory -dot- sweet -at- health -dot- ny -dot- gov>
To: "dick -at- rlhamilton -dot- net" <dick -at- rlhamilton -dot- net>, "techwr-l -at- lists -dot- techwr-l -dot- com" <techwr-l -at- lists -dot- techwr-l -dot- com>
Date: Mon, 12 Jun 2023 12:35:31 +0000

Sorry to be dragging up a stale thread, but as I am catching up on the list, I’ve noticed that you did not get a good semantic reply to your question.

The answer is to use the <caption> element directly after the <table> element to title and describe the table for all users.

<table>
<caption> My example table </caption>
…other stuff…
</table>

If you truly only want the content to be visible to screen readers you can add an ‘sr-only’ class to your stylesheet so that the text is there for screen readers to see but hidden from all others.

<style>
.sr-only {
position: absolute;
top: -30em;
}
</style>
<table>
<caption> My example table<span class=’sr-only’>, This table does not contain real data and can be ignored. It presents information in the following format…</span></caption>
…other stuff…
</table>

Lastly you can apply aria-label, aria-labeledby, or aria-describedby properties to label and describe the table. -label labels the table directly. -labeledby and -describedby reference another element on the page (usually by id) to provide a label or description. -label and -labeledby turn the caption into the default description. Aria cardinal rules prefer the native html method of a <caption> visible to everyone. See: https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/

Cheers!

Greg



On 4/28/23, 4:18 PM, "techwr-l-bounces+gregory -dot- sweet=health -dot- ny -dot- gov -at- lists -dot- techwr-l -dot- com" <techwr-l-bounces+gregory -dot- sweet=health -dot- ny -dot- gov -at- lists -dot- techwr-l -dot- com> wrote:

[You don't often get email from dick -at- rlhamilton -dot- net -dot- Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

ATTENTION: This email came from an external source. Do not open attachments or click on links from unknown senders or unexpected emails.


Is there a way to add alt text to a table?

The alt attribute is not allowed on table, and I don’t see a good alternative.

I know that screen readers can read tables, but in this use case, the column and row labels are the only information of interest (the contents of the cells are examples that don’t add any value).

I’d like to able to add alt text that a screen reader would provide first, so the user could choose to skip the table itself. The alt text would identify the rows and columns and then state that the cell data are samples and don’t need to be read.

Any thoughts on how best to do this?

Thanks,
Richard Hamilton
-------
XML Press
XML for Technical Communicators
https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fxmlpress.net%2F&data=05%7C01%7Cgregory.sweet%40health.ny.gov%7C31bbd07d5ae54358feef08db4825b2e4%7Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0%7C0%7C638183098977695241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Boe%2FOuq3UkXYKctYnAL9wWsomEvQk9wNjS%2FZHiR9m%2Bo%3D&reserved=0<http://xmlpress.net/>
hamilton -at- xmlpress -dot- net



^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Visit TechWhirl for the latest on content technology, content strategy and content development | https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftechwhirl.com%2F&data=05%7C01%7Cgregory.sweet%40health.ny.gov%7C31bbd07d5ae54358feef08db4825b2e4%7Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0%7C0%7C638183098977695241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=F7XCN%2Bk0CugPoG8nBf%2FiAZ5Yu0IQshQsHVv592IDWdE%3D&reserved=0<https://techwhirl.com/>

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You are currently subscribed to TECHWR-L as gregory -dot- sweet -at- health -dot- ny -dot- gov -dot-

To unsubscribe send a blank email to
techwr-l-leave -at- lists -dot- techwr-l -dot- com


Send administrative questions to admin -at- techwr-l -dot- com -dot- Visit
https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.techwhirl.com%2Femail-discussion-groups%2F&data=05%7C01%7Cgregory.sweet%40health.ny.gov%7C31bbd07d5ae54358feef08db4825b2e4%7Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0%7C0%7C638183098977695241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4Wy%2FvlRm3MwhrWUnBHOHoGo%2B3%2BVAUq25NmSZu8VfKHg%3D&reserved=0<http://www.techwhirl.com/email-discussion-groups/> for more resources and info.

Looking for articles on Technical Communications? Head over to our online magazine at https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftechwhirl.com%2F&data=05%7C01%7Cgregory.sweet%40health.ny.gov%7C31bbd07d5ae54358feef08db4825b2e4%7Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0%7C0%7C638183098977695241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ggiyo5MAQByVwBHL5jJWeqgMm2iq1fk4EC%2BBI3WC3as%3D&reserved=0<http://techwhirl.com/>

Looking for the archived Techwr-l email discussions? Search our public email archives @ https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftechwr-l.com%2Farchives&data=05%7C01%7Cgregory.sweet%40health.ny.gov%7C31bbd07d5ae54358feef08db4825b2e4%7Cf46cb8ea79004d108ceb80e8c1c81ee7%7C0%7C0%7C638183098977695241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=GAjo%2BXrP3n88kmI0ZDb4VVfDsTHUVDUr355YReROvng%3D&reserved=0<http://techwr-l.com/archives>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Visit TechWhirl for the latest on content technology, content strategy and content development | https://techwhirl.com

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You are currently subscribed to TECHWR-L as archive -at- web -dot- techwr-l -dot- com -dot-

To unsubscribe send a blank email to
techwr-l-leave -at- lists -dot- techwr-l -dot- com


Send administrative questions to admin -at- techwr-l -dot- com -dot- Visit
http://www.techwhirl.com/email-discussion-groups/ for more resources and info.

Looking for articles on Technical Communications? Head over to our online magazine at http://techwhirl.com

Looking for the archived Techwr-l email discussions? Search our public email archives @ http://techwr-l.com/archives


Previous by Author: RE: Aw: Re: AI-based writing assistants
Previous by Thread: Re: Aw: Re: AI-based writing assistants
Next by Thread: Re: Alt text on HTML tables


What this post helpful? Share it with friends and colleagues:


Sponsored Ads