frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

CSS Web Components for marketing sites (2024)

https://hawkticehurst.com/2024/11/css-web-components-for-marketing-sites/
48•zigzag312•3h ago

Comments

hyperhello•1h ago
The reason fixing ads from the inside won’t work is that they are designed to disrupt. An ad that ruins your scrolling for three seconds is preferable to one that ruins your scrolling for 2.5 seconds. All ads are designed to wreck the environment that they are in, to create a space for irrationality to enter.
vaylian•1h ago
I've never been deep into XSLT, but I kind of have the impression, that this would have solved the issue.
pier25•1h ago
Why not just use CSS?
etchalon•1h ago
It is using CSS.
pbowyer•1h ago
Why not use CSS without the custom element? From this post I don't see the benefit of using <swim-lanes> over <section class="swim-lanes"> for example.
etchalon•48m ago
A handful of benefits:

1. Specificity - swim-line.buttons vs .swin-lines.buttons vs .buttons.swim-lanes. 2. Future pathing - Maybe you don't need a Web Component today, but you might need one tomorrow. 3. Cleaner - <swim-lane /> is just better than <div class="swim-lane" />

Kerrick•13m ago
Arguably, that would be misuse of the semantic meaning of "section." While <section> is nearly as generic as <div>, they should always have a heading of their own. The author's <swim-lane> already has a nested <section> with its own <h2>, but the <swim-lane> itself doesn't get (or need) its own even-higher heading.

And since that would drive us to <div>, I don't see any value in <div class="swim-lanes"> over <swim-lanes>.

spankalee•1h ago
I'm a big web components guy, but calling these web components is a massive stretch of the word component.

The word "component" has to mean something ultimately, and to me the defining feature of a web component is that it's self-contained: it brings along its own dependencies, whether that's JavaScript, templates, CSS, etc. Web components shouldn't require an external framework or external CSS (except for customization by the user) - those things should be implementation details depended on directly by the component.

This here is just CSS using tag names for selectors. The element is doing nothing on its own.

Which is fine! It's just not web components.

edit: Also, don't do this:

    <link-button>
      <a href="">Learn more</a>
    </link-button>
That just adds HTML bloat to the page, something people with a singular focus on eliminating JavaScript often forget to worry about. Too many HTML elements can slow the page to a crawl.

Use classes:

    <a class="button" href="">Learn more</a>
They're meant for this, lighter weight, and highly optimized.
rafram•1h ago
> To many HTML elements can slow the page to a crawl.

You can read the entirety of War and Peace in a single HTML file: https://standardebooks.org/ebooks/leo-tolstoy/war-and-peace/...

A marketing page, SaaS app landing, etc., will not even begin to approach that size, whether or not you add an extra wrapper around your <a>s.

shimman•6m ago
Almost 15,000 elements! I do agree that too many elements can slow a page but from my experience that starts to happen a few hundred thousand elements, at least that's what we'd run into making data visualizations for network topologies (often millions of nodes + edges) but the trick for that was to just render in canvas.
akagusu•1h ago
According to the dictionary, the word component means "a part or element of a larger whole" which I think goes to the opposite direction of "self contained"
lucideer•51m ago
There's a lot of contradictions in this comment.

> it's self-contained: it brings along its own dependencies, whether that's JavaScript, templates, CSS

> Also, don't do this [...] That just adds HTML bloat to the page, something people with a singular focus on eliminating JavaScript often forget to worry about. To many HTML elements can slow the page to a crawl.

A static JS-less page can handle a lot of HTML elements - "HTML bloat" isn't really a thing unless those HTML elements come with performance-impacting behaviour. Which "self-contained" web-components "bringing along their own dependencies" absolutely will.

> shouldn't require an external framework

If you're "bringing along your own dependencies" & you don't have any external framework to manage those dependencies, you're effectively loading each component instance as a kind of "statically linked" entity, whereby those links are in-memory. That's going to bloat your page enormously in all but the simplest of applications.

graypegg•25m ago
I might toss it out there that upcoming changes to attr() [0] as well as typed properties [1] will add some interesting features. Being able to provide a value that's subbed into a stylesheet from the HTML itself is neat.

You can try to get by with auto-generated selectors for every possible value today, ([background="#FFFFFF"]{background: #FFFFFF}[background="#FFFFFE"]{background: #FFFFFE}...) but just mapping attributes to styles 1:1 does begin to feel like a very lightweight component.

(Note... I'm not convinced this is a great idea... but it could be interesting to mess around with.)

[0] https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/V...

[1] https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/A...

senfiaj•1h ago
I'm not a fan of these custom elements. Unless you do something really interactive, dynamic and reusable (an element with complex behavior), I don't think it's worth to use them. The SEO / accessibility becomes more challenging. Also, worth to noting, web components require JS, so they are not pure "CSS" web components. Web components are useful for isolation, when used with shadow DOM.
jakelazaroff•47m ago
Using custom elements as the article suggests doesn't require JavaScript, so they are "pure" HTML and CSS (though whether they count as "web components" is up to you). More to the point, all of the technologies that the term "web components" includes — custom elements, <template> tags, shadow DOM — can be used without JavaScript.

<div> and <span> are semantically neutral, so I'm not sure what SEO and accessibility challenges custom elements would introduce?

kelvindegrees•50m ago
Is this not exactly what DaisyUI (https://daisyui.com) is?
hawkticehurst•31m ago
Author of the blog post here! Since this blog post, I put this idea to practice on the VS Code website (https://code.visualstudio.com/) to create all the interactive graphics on the homepage. Which is a slightly different use case than what I described in the post, but cool and effective none-the-less.

What woud have been a soup of `div` elements with various class names are now more meaningfully named elements like `<top-bar>`, `<chat-container>`, etc. that were mixed and remixed to create all the graphics.

Also no issues regarding performance that we've seen up to this point, which makes sense; browsers are very good and fast at rendering HTML elements (native or custom).

megaman821•13m ago
I have flitered with this in the past and an important note that you are missing from the post, that this type of custom element should only replace divs and spans. These new elements will have no meaning to the document outline or for accessibility.
dgb23•31m ago
I like that the author came to the idea by cross pollination via web components.

However, it's basically describing the "modifiers" part of BEM, which is a pattern that emerged from structuring CSS. Neither custom element or attributes are needed, even though they might feel different.

If you like that kind of pattern to structure CSS, then combining it with custom CSS properties (often called "variables", example: --block-spacing: 2rem) makes it even more modular. These properties follow the cascade rule.

The Microstructure of Wealth Transfer in Prediction Markets

https://www.jbecker.dev/research/prediction-market-microstructure
64•jonbecker•2h ago•30 comments

CSS Web Components for marketing sites (2024)

https://hawkticehurst.com/2024/11/css-web-components-for-marketing-sites/
49•zigzag312•3h ago•19 comments

What came first: the CNAME or the A record?

https://blog.cloudflare.com/cname-a-record-order-dns-standards/
16•linolevan•1h ago•4 comments

Apple testing new App Store design that blurs the line between ads and results

https://9to5mac.com/2026/01/16/iphone-apple-app-store-search-results-ads-new-design/
125•ksec•1h ago•68 comments

GLM-4.7-Flash

https://huggingface.co/zai-org/GLM-4.7-Flash
206•scrlk•3h ago•60 comments

Show HN: Pipenet – A Modern Alternative to Localtunnel

https://pipenet.dev/
27•punkpeye•2h ago•6 comments

A Brief History of Ralph

https://www.humanlayer.dev/blog/brief-history-of-ralph
10•dhorthy•16m ago•2 comments

Iterative image reconstruction using random cubic bézier strokes

https://tangled.org/luthenwald.tngl.sh/splined
34•luthenwald•4d ago•9 comments

A decentralized peer-to-peer messaging application that operates over Bluetooth

https://bitchat.free/
461•no_creativity_•11h ago•264 comments

Bypassing Gemma and Qwen safety with raw strings

https://teendifferent.substack.com/p/apply_chat_template-is-the-safety
7•teendifferent•13h ago•0 comments

Folding NASA Experience into an Origamist's Toolkit

https://spinoff.nasa.gov/Folding_NASA_Experience_into_an_Origamist%E2%80%99s_Toolkit
51•andsoitis•2d ago•4 comments

Cows Can Use Sophisticated Tools

https://nautil.us/the-far-side-had-it-all-wrong-cows-really-can-use-sophisticated-tools-1262026/
33•Tomte•1h ago•12 comments

Radboud University selects Fairphone as standard smartphone for employees

https://www.ru.nl/en/staff/news/radboud-university-selects-fairphone-as-standard-smartphone-for-e...
428•ardentsword•9h ago•199 comments

Luxury Yacht is a desktop app for managing Kubernetes clusters

https://github.com/luxury-yacht/app
43•mooreds•5d ago•13 comments

Dead Internet Theory

https://kudmitry.com/articles/dead-internet-theory/
581•skwee357•21h ago•626 comments

Bootstrapping Bun

https://walters.app/blog/bootstrapping-bun
6•zerf•1h ago•1 comments

Robust Conditional 3D Shape Generation from Casual Captures

https://facebookresearch.github.io/ShapeR/
27•lastdong•6h ago•2 comments

San Francisco coyote swims to Alcatraz

https://www.sfgate.com/local/article/san-francisco-coyote-alcatraz-21302218.php
25•kaycebasques•15h ago•1 comments

Ask HN: COBOL devs, how are AI coding affecting your work?

123•zkid18•5h ago•125 comments

Nepal's Mountainside Teahouses Elevate the Experience for Trekkers

https://www.smithsonianmag.com/travel/nepal-mountainside-teahouses-elevate-experience-trekkers-he...
89•bookofjoe•4d ago•36 comments

Conditions in the Intel 8087 floating-point chip's microcode

https://www.righto.com/2025/12/8087-microcode-conditions.html
6•diogotozzi•4d ago•0 comments

Raccoons break into liquor stores, scale skyscrapers and pick locks

https://theconversation.com/raccoons-break-into-liquor-stores-scale-skyscrapers-and-pick-locks-st...
17•pseudolus•1h ago•4 comments

"Anyone else out there vibe circuit-building?"

https://twitter.com/beneater/status/2012988790709928305
90•thetrustworthy•3h ago•59 comments

Two Concepts of Intelligence

https://cacm.acm.org/blogcacm/two-concepts-of-intelligence/
42•1970-01-01•5d ago•49 comments

Flux 2 Klein pure C inference

https://github.com/antirez/flux2.c
402•antirez•1d ago•130 comments

The Code-Only Agent

https://rijnard.com/blog/the-code-only-agent
131•emersonmacro•15h ago•58 comments

I set all 376 Vim options and I'm still a fool

https://evanhahn.com/i-set-all-376-vim-options-and-im-still-a-fool/
59•todsacerdoti•2d ago•20 comments

The space and motion of communicating agents (2008) [pdf]

https://www.cl.cam.ac.uk/archive/rm135/Bigraphs-draft.pdf
26•dhorthy•3d ago•2 comments

MTOTP: Wouldn't it be nice if you were the 2FA device?

https://github.com/VBranimir/mTOTP/tree/develop
54•brna-2•9h ago•77 comments

Self Sanitizing Door Handle

https://www.jamesdysonaward.org/en-US/2019/project/self-sanitizing-door-handle/
40•rendaw•4d ago•45 comments