frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Show HN: I made Logic gates using CSS if() function

https://yongsk0066.github.io/css_if_logic_gate/
69•yongsk0066•4d ago

Comments

webdevver•6h ago
cant wait to hang pages with ring oscillators
mmastrac•6h ago
I'm a little behind on my CSS, but apparently you can now evaluate styles in the container and act on them, at least in Chrome:

https://developer.chrome.com/blog/new-in-chrome-137

The example uses a newer `style(..)` condition I haven't seen yet:

https://developer.mozilla.org/en-US/docs/Web/CSS/@container#...

I'm curious if you can accidentally make loops using some of these, and if there's some sort of settling/recursion limit.

EDIT: Apparently `style(..)` can only evaluate vars in this `if()`? It looks like `@container` is a way to manage generic style queries and that supports the full gamut of CSS queries.

https://developer.mozilla.org/en-US/docs/Web/CSS/if

  A @container query does have some advantages — you 
  can only set single property values at a time with
  if() style queries, whereas @container queries can
  be used to conditionally apply whole sets of rules.
  The two approaches are complementary, and have
  different uses.

  Note that container style queries currently don't
  support regular CSS properties, just CSS custom 
  properties. For example, the following won't work: [..]
EDIT 2: OK, this required digging out the spec. They cannot cause recursion because of the substitution context rules:

https://drafts.csswg.org/css-values-5/#if-notation

  For example, in --foo: if(style(--foo: bar): baz);
  the style() query is automatically false, since
  property replacement has already established a 
  «"property", "--foo"» substitution context. "
... and there are rules around cyclic evaluation in CSS:

https://drafts.csswg.org/css-values-5/#cyclic-substitution-c...

  When a cycle is detected, all participants in the cycle
  become invalid. For example, all of the following 
  declarations become invalid at computed-value time."
Phew.
jordanscales•5h ago
I assume this is not more powerful computationally than existing selectors, right? What exactly keeps CSS+HTML from being Turing-complete?
shakna•5h ago
If you include the user clicking, then it already is. [0]

[0] https://github.com/brandondong/css-turing-machine

cluckindan•5h ago
Nothing. Given infinite memory, a NAND gate is Turing complete by itself and trivial to construct based on the OP examples.
csmantle•3h ago
Unfortunately the examples provided by OP only contain combinational circuits, which by def. have no memory.
cluckindan•9m ago
Well, there are half and full adders, maybe a flip-flop would be feasible?
amelius•3h ago
Ok, so NoScript should also block (parts of) CSS now, and not just JavaScript?
cdaringe•2h ago
I’m going to assume this is a joke. However, if it’s not a joke, no. We as a community have gone to great lengths to use responsive design over the past few years. There are still styling cases for complex elements that can’t be implemented without JavaScript. This is just an additional step of the journey to allow intermediate styling for complex cases.

If anything, it should enable (minor) expansion of noscript!

cdaringe•2h ago
Id actually like to redact that prior message and think further, here. We already have information egress thru URIs, with some amount of “protection” via CSP. But I didn’t think of other types of attack vectors at length. Someone above remarked that this is just a general form of conditional, which perhaps unlocks new vectors. Im always surprised by CSS so i should slow down and keep an open mind :)
zamadatix•1h ago
It lacks a usable form of pure-CSS recursion (which was intentionally excluded in this implementation) but that's not as big a problem as one would expect for a lot of practical things.
Dylan16807•1h ago
Basic arithmetic plus iteration is Turing complete. CSS has basic arithmetic but not iteration.

Some people have already claimed it's Turing complete by making the user hit tab and space to copy data between iterations, but I wouldn't listen to them. That copying role is simple but it's not negligible.

montroser•5h ago
Neat. But side note: do we really need if() in CSS? Like, the complexity that adds is going to be worth the functionality it brings? It's introducing a whole new paradigm to solve what real problem?
cluckindan•5h ago
See the MDN examples:

https://developer.mozilla.org/en-US/docs/Web/CSS/if

I for one would much rather use local conditionals than do the logical equivalent through conditionally set CSS variables. It is much more readable and extendable than several layers of abstraction (design token vars -> semantic vars -> theme vars potentially complexed by media/container queries -> element styles).

Of course I wouldn’t replace all of that, but if() would certainly make many things easier to grok for the next guy. Just don’t overuse it.

alwillis•3h ago
We already have specialized conditionals in CSS, such as @supports, minmax, media queries, etc.

if() is just a general purpose conditional.

Using if() is going to reduce complexity for a whole range of use cases. Right now, developers are using custom property hacks to simulate true conditionals [1].

[1]: "The --var: ; hack to toggle multiple values with one custom property"—https://lea.verou.me/blog/2020/10/the-var-space-hack-to-togg...

masterj•51m ago
JS is inherently single-threaded and mobile cores aren't really getting faster, but we are getting more of them. Allowing you to express more in CSS means you get faster-loading, more highly-performant, less energy-draining web UIs.
franky47•5h ago
Soon it’ll be shift registers, ALUs, and before we know it we’ll have DOOM in CSS.
Mtinie•4h ago
Not exactly what you are asking for but we’re moving closer to your vision of the future:

https://github.com/yurkagon/Doom-Nukem-CSS

Get the location of the ISS using DNS

https://shkspr.mobi/blog/2025/07/get-the-location-of-the-iss-using-dns/
191•8organicbits•6h ago•68 comments

Functions Are Vectors (2023)

https://thenumb.at/Functions-are-Vectors/
86•azeemba•3h ago•41 comments

Hannah Cairo has solved the Mizohata-Takeuchi conjecture

https://english.elpais.com/science-tech/2025-07-01/a-17-year-old-teen-refutes-a-mathematical-conjecture-proposed-40-years-ago.html
189•leephillips•3h ago•23 comments

Claude Code Pro Limit? Hack It While You Sleep

https://github.com/terryso/claude-auto-resume
47•suchuanyi•3h ago•22 comments

Collatz's Ant and Σ(n)

https://gbragafibra.github.io/2025/07/06/collatz_ant5.html
5•Fibra•1h ago•1 comments

Overthinking GIS (2024)

https://scottsexton.co/post/overthinking_gis/
87•todsacerdoti•10h ago•27 comments

Serving 200M requests per day with a CGI-bin

https://simonwillison.net/2025/Jul/5/cgi-bin-performance/
258•mustache_kimono•18h ago•210 comments

Hidden interface controls that affect usability

https://interactions.acm.org/archive/view/july-august-2025/stop-hiding-my-controls-hidden-interface-controls-are-affecting-usability
520•cxr•19h ago•371 comments

Metriport (YC S22) is hiring engineers to improve healthcare data exchange

https://www.ycombinator.com/companies/metriport/jobs/Rn2Je8M-software-engineer
1•dgoncharov•1h ago

Overclocking LLM Reasoning: Monitoring and Controlling LLM Thinking Path Lengths

https://royeisen.github.io/OverclockingLLMReasoning-paper/
18•limoce•5h ago•0 comments

Take Two: Eshell

http://yummymelon.com/devnull/take-two-eshell.html
93•nanna•3d ago•54 comments

How to get started with Old English poetry

https://www.deadlanguagesociety.com/p/old-english-poetry
21•onthesly•1d ago•6 comments

Eastern Baltic cod grow much smaller than they did due to overfishing

https://www.smithsonianmag.com/smart-news/these-cod-have-been-shrinking-dramatically-for-decades-now-scientists-say-theyve-solved-the-mystery-180986920/
253•littlexsparkee•23h ago•79 comments

What a Hacker Stole from Me

https://mynoise.net/blog.php
306•wonger_•20h ago•86 comments

Reinforcement Learning from Human Feedback (RLHF) in Notebooks

https://github.com/ash80/RLHF_in_notebooks
45•ash_at_hny•4h ago•1 comments

Show HN: Pixel Art Generator Using Genetic Algorithm

https://github.com/Yutarop/ga-pixel-art
7•ponta17•3h ago•2 comments

Toys/Lag: Jerk Monitor

https://nothing.pcarrier.com/posts/lag/
24•ptramo•4h ago•18 comments

Building a Mac app with Claude code

https://www.indragie.com/blog/i-shipped-a-macos-app-built-entirely-by-claude-code
109•gdudeman•3h ago•66 comments

July 5, 1687: When Newton explained why you don't float away

https://multiverseemployeehandbook.com/blog/when-newton-explained-why-you-dont-float-away/
84•TMEHpodcast•14h ago•86 comments

1945 TV Console Showed Two Programs at Once

https://spectrum.ieee.org/dumont-duoscopic-tv-set
5•pseudolus•1d ago•2 comments

Meet Bionode

https://microship.com/meet-bionode/
20•naves•3d ago•3 comments

How to Network as an Introvert

https://aginfer.bearblog.dev/how-to-network-as-an-introvert/
307•agcat•21h ago•112 comments

Development of a transputer ISA board

https://nanochess.org/transputer_board.html
58•nanochess•2d ago•8 comments

The force-feeding of AI features on an unwilling public

https://www.honest-broker.com/p/the-force-feeding-of-ai-on-an-unwilling
298•imartin2k•12h ago•267 comments

Two and a Half Years in GameDev

https://smyachenkov.com/posts/two-and-half-years-in-gamedev/
67•_sJiff•5h ago•14 comments

Local-first software (2019)

https://www.inkandswitch.com/essay/local-first/
793•gasull•1d ago•269 comments

Huawei cloned Qwen and DeepSeek models, claimed as own

https://dilemmaworks.substack.com/p/whistleblower-huawei-cloned-and-renamed
76•dworks•2h ago•35 comments

Europe's first geostationary sounder satellite is launched

https://www.eumetsat.int/europes-first-geostationary-sounder-satellite-launched
216•diggan•1d ago•47 comments

macOS Icon History

https://basicappleguy.com/basicappleblog/macos-icon-history
237•ksec•1d ago•96 comments

ClojureScript from First Principles [video]

https://www.youtube.com/watch?v=An-ImWVppNQ
108•puredanger•3d ago•28 comments