Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7650245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:12:05+00:00 2026-05-31T11:12:05+00:00

I’ve read that it’s bad practice to style content based on HTML5 data-* attributes.

  • 0

I’ve read that it’s bad practice to style content based on HTML5 data-* attributes.

Quote from html5doctor.com:

The presence/absence of a particular data attribute should not be used
as a CSS hook for any styling. Doing so would suggest that the data
you are storing is of immediate importance to the user and should be
marked up in a more semantic and accessible manner.

Could someone shed some more light on this statement or give some examples of why this might negatively impact a user’s experience?

As a really basic example, say I’m using data-attribute-error="404" on elements to give feedback to a script, instead of having to also add error-404, error-500, etc classes on each element for some supplementary styling, couldn’t I just style these like so:

.error { color: red; }
.error[data-attribute-error]:after { content: attr(data-attribute-error); }
.error[data-attribute-error=404] { color: grey; }
.error[data-attribute-error=404]:after { color: red; }
/* etc */

This probably isn’t the best example, and I’m not worried about browser support. I’m just trying to understand the overall concept better.

Seems there would be a lot of cool stuff we could do with CSS3 and custom attributes to style things based on content, keeping our ‘real’ classes more general to handle pure styling that isn’t based on content.

Is this just a general guideline that can be ignored in certain situations, or is it a horrible client-side sin?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:12:07+00:00Added an answer on May 31, 2026 at 11:12 am

    Basically what they’re suggesting is that if the error message, status or number is important enough to present to users then it should be presented in an accessible way. WCAG Guideline 1.4.1 says:

    Use of Color: Color is not used as the only visual means of conveying
    information, indicating an action, prompting a response, or
    distinguishing a visual element. (Level A)

    The other thing to note is content created by CSS is not available to screen readers and other assistive technologies.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.