Bootstrap: Use `<article>`s for cards when appropriate

Created on 21 Feb 2020  路  8Comments  路  Source: twbs/bootstrap

The cards should be articles in our docs. We should have a look at this after https://github.com/twbs/bootstrap/pull/28517 is merged.

accessibility v5

Most helpful comment

a slightly more neutral alternative would also be <section> https://html.spec.whatwg.org/multipage/sections.html#the-section-element which doesn't have that implication that <article> has about being self-contained and being potentially ripped out of the page as a stand-alone complete piece of content.

but otherwise, perhaps keep the markup as <div> elements, but add a note saying that of course these classes can also be applied to other containers, like <section>, <article>, if the authors feel their content requires clearer/stricter structuring (and just in terms of how AT handle stuff, @stevefaulkner reminded me that if a <section> doesn't have a heading, it will be exposed in exactly the same way as a <div>)

All 8 comments

The tests have failed because there is a rule that requires adding headings in all blocks of type

(Consider using "h2" - "h6" elements to add identifying headings to all articles.), but I'm not sure that an element of type "Card" must contain them.

Why should the cards be articles?

Why should the cards be articles?

It's just a semantic improvement. See https://html.spec.whatwg.org/multipage/sections.html#the-article-element

@patrickhlauke can you chime in please?

I personally don't think we can just replace all of our docs cards with articles, hence the validator errors.

I personally don't think we can just replace all of our docs cards with articles, hence the validator errors.

We can't replace _all_ cards and shouldn't ignore these errors indeed.

personally, i'm not sure i see a strong enough need for using <article> in general, unless i was doing something like a list of news items or similar. would developers cargo-cult this for other uses, like notes/panels and that sort of thing? if so, they'll end up overcomplicating their structure for no reason (and making their pages overly verbose for AT users, who'd constantly hear when entering/exiting an article section).

Thanks @patrickhlauke for the insights. That's what I was also afraid of.

a slightly more neutral alternative would also be <section> https://html.spec.whatwg.org/multipage/sections.html#the-section-element which doesn't have that implication that <article> has about being self-contained and being potentially ripped out of the page as a stand-alone complete piece of content.

but otherwise, perhaps keep the markup as <div> elements, but add a note saying that of course these classes can also be applied to other containers, like <section>, <article>, if the authors feel their content requires clearer/stricter structuring (and just in terms of how AT handle stuff, @stevefaulkner reminded me that if a <section> doesn't have a heading, it will be exposed in exactly the same way as a <div>)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

knownasilya picture knownasilya  路  3Comments

kamov picture kamov  路  3Comments

devdelimited picture devdelimited  路  3Comments

eddywashere picture eddywashere  路  3Comments

bellwood picture bellwood  路  3Comments