TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A practical way to test HTML and CSS in real-time using only CSS

6 pointsby tinchox59 months ago
Recently, I made public a CSS framework I developed for creating radial designs. During development, I faced several challenges, including testing different features. I noticed that CSS linters and other tools didn&#x27;t allow me to see why something wasn&#x27;t working, even if there were no basic errors. Another typical CSS problem was seeing how it was shared across different browsers. Fortunately, I discovered that certain new CSS features can be used to create a series of real-time tests. These features are `@support`, `@container`, and `:has()`.<p>By combining these features, I developed a testing system not only to check if the framework works in the browser but also, and most importantly, to see if we are applying HTML correctly according to the browser&#x27;s requirements and avoiding involuntary errors when developing an application.<p>Since my CSS framework necessarily uses features that only the newest browsers have, such as trigonometric functions like `cos()` and `sin()`, I created a series of rules to test if they are supported by the browser. If they&#x27;re not, a message appears asking to update the browser. Similarly, if the browser doesn&#x27;t support `:has()`, which is used throughout the framework.<p>There are also typical cases of browser incompatibility, so in some non-critical cases, I use `@support` or `@container` to hide certain Orbit features that don&#x27;t affect its use. For example, Safari doesn&#x27;t accept SVG `context-stroke`, so I hide them.<p>However, beyond those critical checks and compatibility, the most common issue when using a CSS framework is not knowing how to use it properly. That&#x27;s why I created other CSS rules that allow analyzing if a parent element has the required child elements and not others. Here, visual alerts also appear while developing to give a hint about where the error is in the code.<p>I don&#x27;t want to bore you with the details specific to Orbit, but I&#x27;ll leave you the link to the support source and related documentation.<p>Repo: https:&#x2F;&#x2F;github.com&#x2F;zumerlab&#x2F;orbit<p>Source file: https:&#x2F;&#x2F;github.com&#x2F;zumerlab&#x2F;orbit&#x2F;blob&#x2F;main&#x2F;src&#x2F;scss&#x2F;_support.scss<p>Orbit related documentation: https:&#x2F;&#x2F;zumerlab.github.io&#x2F;orbit-docs&#x2F;tools&#x2F;support&#x2F;<p>Good to go deeper: https:&#x2F;&#x2F;heydonworks.com&#x2F;article&#x2F;testing-html-with-modern-css<p>edited: typo Suorce -&gt; Source

no comments

no comments