Adapting content based on various media queries

After spending more time on this question, I hope to clarify my thoughts better this time around.

I am currently designing a responsive layout for my upcoming landing page. The main header in the body changes based on the browser size and device.

<h1><span class="main__header--changer">COMING SOON</span></h1>

... along with the CSS

@media (max-width: 75em) {
      h1:before {
           content: "HOLD ONTO YOUR HATS";
      }
      .main__header--changer {
           display: none;
      }
 }

 @media (max-width: 64em) {
      h1:before {
           content: "NOT LONG TO GO";
      }
      .main__header--charger {
           display: none;
      }
 }

... and so forth, with different variations of "coming soon" having fewer letters as the screen size decreases, down to just 'nigh'.

The method I'm using to achieve this means that screen readers will not read the heading due to the display:none property. Is there an alternative way to hide the heading visually but still have it read by screen readers?

Thank you

Answer №1

To achieve a hidden effect, one trick is to move the content far beyond the visible screen area using margins or the text-indent property. While not considered completely clean methods, they do help keep your HTML code organized.

For more information on how screen readers interact with CSS-hidden elements, check out this useful discussion.

Additionally, it seems there may have been a typo in the second reference to your CSS class. It should likely be --changer instead of --charger.

As a tip, if the rule

.main__header--changer {display: none;}
remains consistent throughout all media queries, consider placing it outside any queries to avoid duplication and ensure universal application.

We hope you find this information beneficial!

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

Switch list items with more than a quantity of 3

I have a set of unordered list items that I want to display only the first 3 li elements for each when loading. Upon clicking the + sign, the remaining list items should toggle visibility for just that specific list group. While this can potentially be ach ...

Trigger a function when clicking outside the element, similar to how a Bootstrap modal is closed

I have successfully created a popup box using angular in my project. It appears when I click on an icon and disappears when I click on the close button. However, I would like it to also close if someone clicks outside of the popup. Can anyone help me with ...

Looking for assistance in resolving a CSS issue on Google Chrome and Safari browsers

My friend needs some assistance with his website that is currently in development: When viewing the website in Firefox, everything looks fine. However, when using Chrome or Safari, there is a strike-through bug appearing in the product description as show ...

Load Bootstrap CSS file externally on a website dynamically

Although my knowledge of JavaScript is limited, I am the recipient of a small web application from a friend that is being utilized by multiple companies. As each company requires specific modifications in the appearance and CSS of certain webpages, it can ...

Navigate through photos (jQuery) to adjust size and location dynamically (CSS)

Currently, I am in the process of developing a jQuery script that will automatically adjust the size and position of image elements upon page load or resize. To structure my layout, I am utilizing Bootstrap and have set a fixed height using CSS. It is wort ...

How can I attach an event listener to each row in a table that is dynamically generated?

I am currently working on a table that is being populated using data from a JSON file. The number of entries in the JSON file can vary, resulting in different lengths for the table rows. Each row includes a bootstrap dropdown button with links for actions ...

Mediawiki needs to be able to respond effectively to constantly changing and evolving content

My extension generates content dynamically for certain pages. For example, I create headlines using <html> <h1>, <h2> and <h3> tags. I want my mediawiki to respond to these headlines and generate a directory dynamically. I attempte ...

In the world of web design, IE6 has a peculiar quirk where it still displays

This example is created to showcase a specific problem. In between two paragraphs, there's a div element with its height and line-height set to 0, along with margins at 0 as well. Ideally, the paragraphs should be right next to each other without any ...

Encountering an unusual hash code when implementing Google Tag Manager in a Next.js project was

I am currently using Next.js and have added Google Tag Manager through a script <script dangerouslySetInnerHTML={{ __html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var ...

Eliminate any unnecessary or hidden spacing on the left side of the options within an HTML select

Currently, I am in the process of creating a Registration Form and encountering a challenge with aligning the input[type="text"] placeholder and the "pseudo" placeholder for a <select> element. My goal is to have both placeholders left-aligned flush ...

Unusual SASS results observed while utilizing extends functionality

Having issues with my SASS files: _android.scss: $width: 111px; @import 'child'; .android .child { @extend %child; } _ios.scss: $width: 999px; @import 'child'; .ios .child { @extend %child; } _child.scss: %child { wi ...

Establishing updated file path for resources in JavaScript based on environment

I'm currently facing an issue with my external Javascript file that uses the getScript() function to execute another JS file. Both files are located on static.mydomain.com, as I am trying to set up a Content Delivery Network (CDN) for the first time. ...

Tips for inserting a placeholder into a form input field

I am currently working on developing a form displayed in this fiddle. My goal is to fit an entire placeholder text into the form. Here is the HTML I've used to create a compact input form: <div class="container text-center "> <div class= ...

Guide to configuring a background image from the public folder in a React application using Create React App

How do I properly set a background image in a .css file located in the src folder? src/Components/Component/Comp.css .services { background-image : url("./images/img-2.jpg"); background-position: center; background-size : cover; b ...

A guide on using key arrows in JavaScript to navigate and focus on elements

When working on my HTML project, I have a list of elements that I want to be able to select using the arrow keys. I've included my code here for reference: [http://jsfiddle.net/T8S7c/] What I'm trying to achieve is when the arrow keys are press ...

What is the best way to incorporate a sliding effect into my cookie form?

I created a cookie consent form for my website and I'm looking to include a sliding effect when it first appears and when it disappears after the button is clicked. How can I implement this sliding effect into the form? Here's the HTML, CSS, and ...

CSS smoothly scrolls upward within a set height restriction

Is there a way to use CSS to ensure that the scroll bar of a fixed-height message box is always at the bottom, displaying the latest entry? Currently, as more messages populate the chat box main section, everything inside remains static. The only way to v ...

"Using html_attr with the attribute "href" does not return any value in the rvest package

My objective is to extract the URLs linked with specific CSS elements on a website using rvest. Despite trying various methods, such as using the html_attr function with the 'href' argument, my current script only returns NA values instead of the ...

Tips for efficiently implementing AJAX requests for multiple forms within a single webpage

Previously, I had a form where clicking submit would hide the form and display the result on a div with classname=dig. However, after adding more forms, all the forms started submitting at the same time instead of individually. How can I fix this issue in ...

Setting the root position of a div: How can it be done?

Imagine a scenario where a div element is designed to follow the mouse cursor on the screen. This functionality is achieved by manipulating the document's `mousemove` event and adjusting the div's `left` and `top` positions based on the event dat ...