New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for correct order of heading tags #13
Comments
I like this idea, but your last point was main concern. It's more common for headings to not be in the same scope. Let me consult @danspratling on ideas for this too. 🤔 |
You can use the Thinking about how you'd apply this you could do something like
Without testing this in actual code though I'm not sure if this is robust enough. Maybe it is, as once an h2 is present an h3 can be placed after it multiple times if required, which this should evaluate correctly. |
Hmm interesting. @SavvasStephanides if you'd like to, feel free to experiment this and see what you can find out? 😊 Or we can pick it up at some point. |
Here's a pen I created quickly which covers how this should work. Seems robust enough to me |
That solution could be improved –correct me if I'm wrong– by adding the universal operator in this way:
Although it may not be too efficient, it will capture more cases as it considers a more realistic use of the headings in HTML (e.g., headings are rarely at the same level, they are normally within their own container/section.) Here is a codepen with a demo: https://codepen.io/alvaromontoro/pen/OJNeJwX |
This could potentially be integrated with something similar to what Una Kravets suggested once on Twitter (look at the second tweet as it's more accurate). Her solution targets a slightly different thing (but both cases highlight errors that need to be fixed.) |
Edit: Just read through all this again and I definitely need to stop looking at issues when I'm sleepy! Both of your suggestions are right. Would you be happy to create a PR incorporating them? |
@alvaromontoro Thanks for this. I don't know if I'm missing something here but it doesn't seem to catch it when a |
@SavvasStephanides That's why I mentioned that both solutions targeted different things:
They can be combined and they'll highlight wrong headings correctly. The only "issue" is that sometimes they will highlight both sides. E.g., if you have h1-h3-h2, your method will highlight h3, Una's will highlight h2, combining both will highlight h3 and h2... I don't even know if that can be considered an issue at all. |
@alvaromontoro are there any flaws in your proposed CodePen? https://codepen.io/alvaromontoro/pen/OJNeJwX |
@jackdomleo7 I think combining both methods like in the demo works fine. If you want I can pick this ticket (if it's not pre-assigned to anyone) |
@alvaromontoro only if you want to, that'd be great! 😊 If not, don't worry, I was just gathering any missing information. |
Assign it to me then. I'll work on it. |
Found a bug in the demo... Need to add all the possible combinations of * and no-*. The rule is big and bugly, but now it seems to work fine. |
Headings should be in the correct order See here for more information.
For example, this is correct:
This is incorrect because it goes from
h1
straight toh3
(skippingh2
):Not completely sure how this can be done with
CSS
. I have tried thiswhich checks if an
h1
heading is followed by anh3
orh4
header. However, this doesn't take into account elements in between the headers. Any ideas welcome.The text was updated successfully, but these errors were encountered: