How to skip some content from screen reader - html

I want to skip some content from reading of screen reader.
consider this html
<div id="test" aria-labelledby="test>
...
<div aria-hidden="true">Dont read this content. This content will be loaded from javascript</div>
...
</div>
Though the aria-hidden=true is set for the div, the content is read by screen reader. Please help to skip this content

Your code looks right, how are you testing this?
Not all browsers / screen readers will support this yet.
Try setting style="display:none;" as this may be more widely supported at the moment.

Related

Dynamically toggle content appearance with before & content Vs. div & display - CSS only

I'm trying to toggle a small chunk of content being displayed on my site depending on how wide the screen is. If you visit my site you'll notice the three "<" marks next to the area that says "Coding is in my DNA". If you shrink your browser window down to less than 800px you should see the text become centered and the three "<" disappear. There are two ways that I know how to do this but currently I'm using the following code to achieve this:
Method A -
HTML:
<div id="home-title" class="col-xs-12 col-sm-6 col-md-5">
Thanks for visiting
<h2>DigitalBrent.com</h2>
<div id="sub-head">Coding is in my DNA</div>
</div>
CSS:
#sub-head::before{
content: "<<<";
}
#media(max-width: 800px){
#sub-head::before{
content: "";
}
}
But it also works if you do it like this...
Method B -
HTML:
<div id="home-title" class="col-xs-12 col-sm-6 col-md-5">
Thanks for visiting
<h2>DigitalBrent.com</h2>
<div id="sub-head"><div id="arrows"><<< </div><div id="dont-hide">Coding is in my DNA</div></div>
</div>
CSS:
#arrows, #dont-hide{
display: inline-block;
}
#media(max-width: 800px){
#arrows{
display: none;
}
}
I went for method A because it's just a little less coding. But I am wondering what the benefits and disadvantages might be for using method A or method B to show/hide content.
Some questions -
Is there any harm in toggling the content using the CSS before
selector?
When does the before content get rendered in relation to
page load?
Is one of these methods more reliable on the other or will one method effect page load times more than the other (maybe on this small scale it won't make a difference but if it were on a larger scale would the methodology matter)?
Is one method generally considered "better practice" than the other for hiding content or is it entirely personal preference?
I'm sure there must also be things I haven't accounted for such as readability, screen readers, maybe some browser compatibility issues, how does it effect SEO (Again, SEO is probably only relevant to a much larger section of content but I'd still like to know for future reference), etc.
This is a fantastic question.
I wouldn't say there's a serious harm. It is indeed less supported than going with the classic display: none (not supported on < IE8 and your syntax of double colon would break on IE8).
In your case, until the browser parses your CSS and sees that content rule, the content won't be there. While using Method B, before parsing the CSS, the content is instead visible.
Definitely generating content through pseudo-elements will affect loading times. However, it will most likely not be significative, specially on your specific case. Here's a fantastic benchmark done by someone on another question.
I would say that is entirely up to you. The content you're adding is merely aesthetical so you shouldn't care about not being parsed by search engines; the performance hit is barely noticeable and browser compatibility is good enough on general scenarios for both methods.

Accessibility: Tab order within a specific section only

I'm facing a scenario where I need to tell screen readers to read content in order in a specific section only given that the HTML mark up is not in order.
Here is the HTML
<!-- Everything above this section -->
<div class="section-of-concern">
<div id="div2" style="float: right"></div>
<div id="div1" style="float: left"></div>
</div>
<!-- Everything below this section -->
The browser renders this markup and puts div1 to the left and div2 to the right. But screen readers think that div2 is coming first since the markup for it is coming first. I was wonder if there is a way to correct this with some attributes rather than changing the entire design.
Until the AT and browser vendors provide full support for the aria-flowto attribute, your only solution is to change the DOM order to reflect the visual order and modify your CSS so that your visual presentation remains the same.
Maybe you can use the tabindex. The tabindex attribute can be used to include additional elements in the tab order and to set programmatic focus to them to order the elements, for example:
tabindex="X" (where X is a positive integer between 1 and 32768)
For more information: http://www.w3.org/TR/2009/WD-wai-aria-practices-20090224/#focus_tabindex

iOS Accessibility Voiceover Reads Out Unnecessary Content in Web

My iPhone application is built using Cordova and it for the most part native and I am having an issue with Accessibility. During my accessibility testing I noticed that when Voice Over is selected on some elements it reads out more than just the text of the label or button. For instance here is what a pages header looks like in my HTML:
<div data-role="header">
<div class="page-header">
<h1 class="header-title"><%= title %></h1>
</div>
</div>
When H1 is selected the following is read out to the user:
Banner Title Heading Level 1 Landmark
Is there any way to restrict it to only speak out the title content?
Looks like you are using jQuery Mobile. jQuery mobile adds some markup to the elements based on where you have placed them and the attributes applied. In this case it is placing role="banner" on the div with the data-role="header".
The way that is being read out is fine. If you are in fact using the header as a header, then the screen reader user now has that useful piece of information. If they do not want it, they can tell their screen reader to suppress it. Think of it as the audio equivalent of the fact that the header is visually distinct from the rest of the page.

HTML Document markup for accessibility

I was wondering about a proper way of structuring a document-like html page. It's obvious that the title of the page should be marked as <h1> and section headings as <h2>.
As for the footer, right now, I have:
<div id="footer">Footer content</div>
and this will be displayed in every page of the document. I realized that screen reader will not notify the users if it's reading the footer content. I feel that uses should have the option to skip reading the footer content.
Is it necessary to let screen reader announce that it's going to read the footer content and is there a proper way to do so?
Thanks!
A common way to allow screen readers to skip over repeated parts of your website are to include hidden a anchor to a position right after the element you'd like to skip.
For example, on one of our websites, we do this to allow skipping over our navigation bar.
<div id="navbar">
<a title="Skip Navigation" href="#skipnav"></a>
<img id="home" src="transparent.gif" alt="Home" />
...
</div>
<a id="skipnav"></a>
The "Skip Navigation" a is selectable by using the keyboard and the screen reader will read "Skip Navigation". The user can then "click" on it to jump later into the page. In this case, right after the navigation.
Can you use html5? If so it contains a <footer> tag.
I'm a screen reader user and the h1 and h2 headings will work well. There's no good way to allow a screen reader to skip certain text that I know of which will work with all screen readers and browsers. Assuming your content is something like the following though
<h1>title</h1>
<h2>section1</h2>
section content
<div id="footer">Footer content</div>
<h2>section2</h2>
section 2 content
<div id="footer">Footer content</div>
A screen reader user should be able to figure out they hit the footer again after hearing it the first time. They can then use quick navigation keys provided by all modern screen readers to skip to the next heading thus not listening to the footer again.

Is there a way to write content that screen readers will ignore?

I've just been working on a page which needs to be accessible to both sighted and visually impaired users. Some elements of the content, just by the nature of relating only to visual elements, simply do not apply to people using screen readers. For example, a link opens an audio-visual presentation in a new window, but due to circumstances beyond my control, the window is awkwardly resized, so there's a message saying that you should resize the window so you can see everything better. Obviously this is useless information to someone who can't see it anyway.
Is there an accepted way to make screen readers ignore some content?
Actually the correct way of doing this is by using the ARIA role=hidden.
Like this:
<button type="button">
<span aria-hidden="true" class="icon">></span>
<span class="hide">Go!</span>
</button>
By doing this you hide the > character so screen-readers won't read "right angle bracket", and instead read "Go!". Sighted users will only see > if you hide the content in the .hide class visually.
Like this:
.hide{
position: absolute;
left:-999em;
}
The ARIA role presentation is for "normalizing" semantic meaning, like for example a <table> with role="presentation" won't be read as table content and will be just plain text.
If you want an image not to be read you can put in empty alt text like this:
<img src="decorative-flower.jpg" alt=""/>
..or if it's an <svg> omit the <title> and <description>
<svg>
<!-- <title>Remove this line</title> -->
<!-- <description> Remove this too..</description> -->
</svg>
I have noticed in some rare situations some screen-readers have still read the empty alt images, so you could use aria-hidden="true" here as well.
CSS' speak property is not supported at this point, and the same goes for the link attribute media="aural".
Halfway through writing the question I remembered where to look.
CSS can do this:
<span class="dontRead">Screen readers shouldn't read this</span>
.dontRead {
speak: none;
}
check for this
<h1 role="presentation" tabindex="-1">Some text that screen readers will ignore </h1>
because of role="presentation" and tabindex="-1" screen reader will ignore above tag.
i checked this on ie8 and firefox 3.5 it is working with JAWS screen reader.
CSS has those aural properties, but as they aren't implemented anywhere they are completely useless.
The issue with hiding specific pieces of information from users of assistive technologies is that it assumes they are using your software alone in some dark room, which simply not a safe assumption. Many users of assistive technology collaborate closely with other users (to whom this information would be relevant), and a few very fortunate ones even have assistants. You would be wise to de-emphasize or under-prioritize this content for them instead by placing it later in the document somehow.