8 ms·
One thing I consistently dislike in these efforts is the misappropriation of HTML tags with certain semantics. In this instance, the <article> elements should
by chrismorgan 6y ago
One thing I consistently dislike in these efforts is the misappropriation of HTML tags with certain semantics.
In this instance, the <article> elements should not be articles: they’re not complete, standalone items. To be sure, as https://html.spec.whatwg.org/multipage/sections.html#article-or-section https://html.spec.whatwg.org/multipage/sections.html#article... says, there’s subjectivity in deciding whether to use <section> or <article>, but I’m content to say that <article> is wrong here.
(Last time I looked into one of these classless CSS starter files, it was <aside> being used for cards, which was very wrong.)
In a case like this, I’d prefer the inner elements to be <section> or <div>. Or better still, just start using custom element names which are perfectly valid, e.g. <grid-card>. There, no class. I will permit you to claim that that’s cheating and avoiding the point of classlessness; I don’t mind.
But the big pitfall of trying to go fully classless (if you interpret that as also meaning you can’t use your own custom element names) is when HTML just doesn’t have tags for the semantic concepts you’re trying to express. You want a quote, table numbered list? Yeah, we’ve got tags for those things, go knock yourself out. But you want a card? Here, have an article within a section. … what? That ain’t semantic. How’s an author supposed to guess that those tags will present like that? That’s what classes or autonomous custom elements are good for, indicating intent.
- yoz-y 6y agoAgreed. A good classless CSS file should work as a drop-in replacement for the native browser spreadsheet, it should definitely not try to invent it's own semantics. Not that you can't do that, but if you do you are creating a CSS framework, not a stylesheet.
- vladocar 6y agoMy point wasn't to replace the classic class grid, just to give basic HTML5 grid if necessary. You can always add any other CSS Framework for grid formatting. About <section> and other HTML5 tags.. you can always personalise the code to your standards. The grid is based on this: parent element {display: flex; flex-flow: row wrap} child element {flex:1} Replace the parent element (container) with any HTML element, replace the child element with your preferred semantic element.
- javajosh 6y agoGreat reply, Vlad. Your code is really small and tight, and it's easy to modify, just as you say. That's one of the benefit of writing in the style that you did: modern, using all of modern CSS's native goodness. Which means its small, static, no build, and easy to modify. Very nice work.
- globular-toast 6y agoWhat is a card? For me that is purely stylistic and should live in the CSS alone. What does a card mean to a blind user? This is all very easy when you're in the business of marking up documents. It turns out that the handful of element types defined in HTML are good enough for the vast majority of documents. It's quite rare to need to introduce a new tag. The difficulty starts when you're actually trying to create a "user interface" rather than a document.
- runarberg 6y agoFor me, cards are usually lists of self contained items (usually summaries). So the cards parent is usually a `<ul>` or `<ol>` and the card them selfs are `<li>` with a single `<article>`, `<aside>`, or `<figure>`.
- parhamn 6y ago> One thing I consistently dislike in these efforts is the misappropriation of HTML tags with certain semantics. As a counterpoint, I don't understand people pushing strict semantics in html elements where they're not really strictly defined or generally useful. Because of how loose the spec with how these things can be used (it it weren't it'd be like schema.org meets html) scraper and other UI tools don't really look for these things and are very flexible in parsing and identifying structure. It'd be foolish to implement a html parser for the general web that strictly expects articles to be in article tags. Browser default CSS for these things mostly suck and are rarely used, in this case they're overriding them anyway. So why stay pseudo-semantic? Besides general accessibility (which is tag attribute based mostly), its not obvious to me how this critique is repeated so often with such little value.
- detaro 6y ago"you don't need CSS classes, but instead need to add aria-tags overriding the accessibility semantics" kind of invalidates the point of something like this IMHO.
- FideoSpecial 6y agoCreating true accessibility is very difficult in my experience and involves a lot more than tag attributes. Screen readers like JAWS can be, again, very difficult to work with - so being as semantic as possible and maintaining "flattened" HTML are often necessary to get them to work properly for blind users.
- chrismorgan 6y agoThe problem of semantics is two-fold: you’re abusing one thing’s semantics (built-in HTML elements, ending up with something unsemantic in name or functionality), in order to avoid using one of the two mechanisms that are designed for naming semantics in styling and potentially functionality (which are: classes and custom elements). The effects of the semantic abuse are admittedly slight, but they are still present, so all else being equal you should care at least a little about them. Tools like screen readers do distinguish between section, article and div in their landmark handling. By abusing these things, you are making life just a little bit harder for users of screen readers.
- desireco42 6y agoI started reading what you wrote with the complete disagreement of what I thought you are saying and finished agreeing completely. :) I find a good starter defaults good.
- runarberg 6y agoFunny enough, I often mark up grid cards as an unordered list of articles: <ul> <li> <article>Card 1</article> </li> <li> <article>Card 2</article> </li> </ul> Since grid cards are often complete stand-alone items with their own headings, footings and body content.
- ravenstine 6y agoYou're not wrong, but I'll note that the definition of <article> you are referring to seems pretty useless, and I don't think it's wrong for people to generally decide what <article> should mean. I don't see anywhere that defines <aside> as being used for cards. But <aside> should be used for cards if the card itself is an aside. > Here, have an article within a section. … what? That ain’t semantic. What's not semantic about that? An article =/= a page. A page can have multiple articles; the idea of an "article" is pretty abstract.
- awb 6y ago> But <aside> should be used for cards if the card itself is an aside. That's exactly how I treat cards with MVP.css. Note: "aside" doesn't mean it visually needs to be "on the side", just complimentary to the body content. https://andybrewer.github.io/mvp/ https://andybrewer.github.io/mvp/
- chrismorgan 6y agoI still strongly oppose your use of aside there. (And it was indeed that that I was referring to in my original comment here.) Those cards are part of the flow of the document, not tangentially related to the adjacent content.
- awb 6y agoI don't think it's that dissimilar to Mozilla's usage here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside#Using_%3Caside%3E https://developer.mozilla.org/en-US/docs/Web/HTML/Element/as... The 1st `<p>` talks about the movie and the `<aside>` talks about a feature/statistic related to the movie. In mine, the main content talks about the what the library is and how to use it and `<aside>` is used to call out specific features related to the library. In either, the "feature" content could be part of the main content or called out separately and both would seem reasonable to me. Sure, if there was a `<card>` element, that would be a better fit, but the definition of an `<aside>` is broad enough IMO ("indirectly related content") that feature callouts don't seem totally counter to the spirit of the tag.
- divbzero 6y agoAgreed with your overall point that HTML tags should not be misappropriated. This can be a challenge for purely classless CSS because a style can correspond to different semantics in different scenarios. For example, the cards as used in Basic.css [1] are semantically <section>s. But in a different context, cards could be used for an <aside> [2] or for a social media post which would indeed be an <article> [3]. [1]: https://vladocar.github.io/Basic.css/ https://vladocar.github.io/Basic.css/ [2]: https://getbootstrap.com/docs/4.5/components/card/ https://getbootstrap.com/docs/4.5/components/card/ [3]: https://html.spec.whatwg.org/multipage/sections.html#article-or-section https://html.spec.whatwg.org/multipage/sections.html#article...