Skip to content

Utilising semantic tags to provide better structure for screen readers - #1464

Merged
smallsaucepan merged 9 commits into
MLTSHP:dev-v5from
smallsaucepan:macro-semantic-tags
May 24, 2026
Merged

Utilising semantic tags to provide better structure for screen readers#1464
smallsaucepan merged 9 commits into
MLTSHP:dev-v5from
smallsaucepan:macro-semantic-tags

Conversation

@smallsaucepan

Copy link
Copy Markdown
Contributor

Overview

Utilising semantic tags (main, header, article, nav, etc) instead of divs and reordering content in HTML to header, "content", aside, footer to provide better structure for screen readers. Subset of intended changes seeking feedback on approach. Will make further commits based on feedback.

Screenshots

Only visual change should be to alignment of Older and Newer pagination buttons on mobile. They have been moved closer to edge of screen and should line up with edge of image content.

Screenshot 2026-03-08 at 13 19 00

Testing

Have only done a subset of screens initially. Seeking feedback before converting them all. Main ones done are:

  • Base
    • Layouts
  • Components
    • Image
      • List View
      • Lengthy Content
      • Comments Open
    • Pagination
  • Areas
    • FAQ
    • Find Shakes
    • Incoming
    • Legal
    • Relationships
    • Settings
    • Shake

Pages should look and behave as they currently do, albeit with different behind the scenes markup.

Some design decisions worth noting:

  1. Previously a list of image posts consisted of alternating header and content sibling divs. Each post (header and content) has been wrapped in an article tag to identify it as self contained content.
  2. With paginated results the list being paginated no longer displays a trailing divider (assumes there will be pagination). Instead the pagination control takes responsibility for placing a preceding divider.

…ontent in HTML to header, "content", aside, footer to provide better structure for screen readers. Subset of intended changes seeking feedback on approach.
@smallsaucepan
smallsaucepan requested a review from spaceninja March 8, 2026 02:26

@spaceninja spaceninja left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heya! Just wanna say that overall I think this is a good change, and I'm happy to see it.

That said, you've made two changes at the same time that make this PR difficult to review — You've made simple markup changes (div to main, followers-list class, updating some profiles, etc), and you've reordered some markup (moving the main body content first, with the sidebar following). I like these both, but when they both happen in the same file, the diff becomes useless, because there's just one huge chunk of changes from the order change, and any other changes are hidden.

Can you tease these apart and make one PR with the order changes and another with the markup changes? I'm happy to approve them both, but for the PR where you're moving the code around, please don't make any other changes, so the review is simply "this block of code moved down the page"

… sidebar to end of file) to allow for easier diffing of this PR. Will re-apply in a subsequent PR.
@smallsaucepan

Copy link
Copy Markdown
Contributor Author

Easy done. Have rolled back the reordering changes to be reapplied in a subsequent PR.

@spaceninja spaceninja left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for breaking this apart, it was much easier to review.

This is looking good! A few nitpicks and then I'm happy to merge.

Also, could you add an UNRELEASED section to the top of the changelog file listing all the breaking markup changes that will need to be applied in the MLTSHP app? (Or you can do that in the followup PR, if that makes more sense, but it'll need to be done before we bump the version)

<a class="btn btn-secondary btn-shadow" href="#">Newer »</a>
</div>
</div>
<nav class="linear-navigation" aria-label="Timeline">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this the only one with an aria-label?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the most obvious one to me where a label would help. Not meant to be an exhaustive list though - just an example and conversation starter for this PR.

Comment thread src/layout/_page.scss
}

> * {
min-width: 0; // https://github.com/philipwalton/flexbugs/issues/39

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you confirm that word-wrap works properly in flex containers in Firefox now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, will probably have to add this back in. However existing selector was causing problems with restructured HTML as it is.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question stands

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have added back in.

Comment thread src/components/pagination/examples/linear.html Outdated
@smallsaucepan

Copy link
Copy Markdown
Contributor Author

Have addressed the feedback as best I can for now. Should I proceed like so from here?

  1. finalise any remaining semantic tag changes (minus section reordering) and commit to this PR
  2. submit reordered sections as a second PR
  3. submit odds and ends (like word-wrap in flex containers) as a third PR

Suspect there will be things to tidy up after reordering, hence third PR.

@spaceninja

Copy link
Copy Markdown
Member

Sounds like a great plan! Ping me when you're ready for another review on this PR. 🎉

…stead defer to the container to do that e.g. image-content-list li elements. Hoisted image-content-list exceptions out of image-content and image-title (letting the image itself not worry about that). Flattened out image-content section to avoid unnecessary nesting e.g. div > form, when we can just use form. More use of flex gap on containers instead of individual components setting their own margins.
Comment thread src/components/images/partials/_image-footer.scss
…tags. Reworked a fair bit of CSS too to use flexbox more, retire some floats and clear fixes, and move responsibility for spacing between individual components to the wrapping elements.
@smallsaucepan

Copy link
Copy Markdown
Contributor Author

Latest round of updates:

  • BEM-ified a few top level components - post, comment
  • Flattened some areas (like title + title editor now siblings rather than parent child) so we can have identical markup for title whether on editable page or not
  • Where possible stripped singleton components back to not worry about setting their own spacing in lists - let the container do that
  • Added some example comments in a few areas (incoming, shake) to make sure they work properly in those contexts

Diagrams below might help visualise intended structure:

Post

mltshp-bem-post

Comment

mltshp-bem-comment

@spaceninja spaceninja left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran out of time to review in the browser, but wanted to share some code review feedback first.

Also, one request: Since this PR is making so many breaking markup changes, I'd like to see you document them in the changelog to ensure the changes are documented. I know you'll likely be the one implementing the changes in the main repo, but it's good practice to document changes like this. I'd expect something like:

  • Change <div class="main"> to <main>
  • Change <div class="sidebar"> to <aside>
  • Replace old-class with new-class
  • etc

Oh, and you've got a CI failure due to linting. If it's prettier, you can probably auto-fix by running npm run lint

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections to these changes, but just so you're aware, the API documentation is automatically generated, so these changes may or may not be something we have control over. I think the pattern library page should accurately reflect the markup on the site, so it might be worth checking in the main repo if that's something we can control or not before updating it here.

@smallsaucepan smallsaucepan Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll double check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patterns API page currently embeds the entire page, including wrapper and page footer. Should that be pared back to what other areas include? It seems to be the exception at the moment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine — I think I just copy-pasted the whole thing for ease of maintenance. As long as we can see the markup in the pattern library so we can review CSS styles, that's all that really matters.

@smallsaucepan smallsaucepan Apr 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll trim it back then to just the content to bring it in line with all the others. To leave it means extra wrapper markup that might go stale.

If the generated html needs to adjust to meet the styles half way will take care of that in the mltshp repo.

Comment thread eleventy.config.js Outdated
Comment thread src/components/images/examples/no-comments.html Outdated
Comment thread src/components/image-comments/_image-comments.scss
box-shadow: none;
}

&--blank {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general rule of thumb, I'd prefer that we avoid using Sass to construct selectors like this — it doesn't save much typing, and it makes maintenance harder, because you can no longer search for the class. The other changes in this file are fine, but please change these to the full class name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy done. Will fix these up.

a {
@include links.link-primary;
}
&--blank {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same concern about constructed selectors. Please use the full class name to allow for search.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

.image-edit-title:focus,
.image-edit-title-hover {
background-color: var(--color-status-edit);
&--editable:hover,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, please don't use Sass to construct selectors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/layout/_page.scss
}

> * {
min-width: 0; // https://github.com/philipwalton/flexbugs/issues/39

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question stands

@smallsaucepan

Copy link
Copy Markdown
Contributor Author

Sure. I'll flesh out the changes in the changelog on this PR.

Correct. CI build was a minor linting issue. Felt it could wait until next commit to avoid complicating any reviewing.

…es that will be required to mltshp repo. Addressed some scss usage, as well as re-enabling uniqueness check in 11ty. Also identified a few issues highlighted by proceeding (in dev) with making the changes to the mltshp code proper.
@spaceninja

Copy link
Copy Markdown
Member

Since browser review is time-consuming, I'll hold off on any further review for now. Broadly speaking, you're heading in the right direction. Looking good!

@smallsaucepan

Copy link
Copy Markdown
Contributor Author

That's probably it for this PR then (if we're going to leave re-ordering sections for a subsequent one).

Rather than merging this in to main and moving on to the next step, how about we create a new branch and work there until it's all ready to go? Means you could still release minor fixes from main, and keeps this work insulated.

dev-v5 or something along those lines?

@smallsaucepan
smallsaucepan requested a review from spaceninja April 4, 2026 23:26
@spaceninja

Copy link
Copy Markdown
Member

Rather than merging this in to main and moving on to the next step, how about we create a new branch and work there until it's all ready to go? Means you could still release minor fixes from main, and keeps this work insulated.

Sounds good to me

@smallsaucepan
smallsaucepan changed the base branch from main to dev-v5 April 12, 2026 23:23
@spaceninja

Copy link
Copy Markdown
Member

@smallsaucepan What's the status here? No pressure, just trying to make sure you're not blocked by me failing to do something?

@smallsaucepan

Copy link
Copy Markdown
Contributor Author

All good @spaceninja. I'll merge this onto the dev branch and go from there. There's also MLTSHP/mltshp#865 in play, which would have some overlap with this (classnames, etc).

@smallsaucepan
smallsaucepan merged commit 51be5dd into MLTSHP:dev-v5 May 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants