:root { --color: blue; }
div { --color: green; }
#alert { --color: red; }
* { color: var(--color); }
<p>I inherited blue from the root element!</p>
<div>I got green set directly on me!</div>
<div id='alert'>
While I got red set directly on me!
<p>I’m red too, because of inheritance!</p>
</div>
Excuse my negativity, but this is messed up. I am trying to rationalize whyyyy???.It seems every object is given variables (--abc). And then there are global variables and local variables. I guess this is the "cascading" feature. var is a function computed at the time of instantiation. And refers to local variables first. Then looks at global variable. Inheritance comes from ?? The p tag seems it is not root so therefore it is not blue.
Having explained it, I think about it better, but this really messes up how I thought of CSS. CSS is where the second stanza overwrites the first stanza. Yet global and local variables really hurts my head. A few complex CSS files later, it is bound to be unusable to determine result without getting a computer program to help.
In the last line of CSS, you went on to equate a built-in property with the value of the variable everywhere. So you’ve essentially made a new “property” that works just like the builtin color property.
(Disclaimer: I’m not an expert in modern CSS, so this could be imprecise.)
Nit: only inherited properties are inherited.
For example color and font-family are, while padding and background-color are not.
One of the special rules you kind of just need to get a feel for that makes CSS a little inscrutable to those who don’t practise it every day.
#alert { color: red }
* { color: blue }
Variables behave slightly differently, in that they don't follow specificity rules. The definition of the variable / property behaves like a scope, and affects everything within it, hence the <p> being colored red instead of blue.Variables don't follow specificity in the same sense that other properties don't follow specificity. Specificity only applies to rules in the first place, not to properties.
I am out of my comfort zone here, but if that were true then at least I’d find it understandable. Variables act like properties and rules still act like rules.
Variables don't use specificity like CSS selectors. I prefer to create a few layers for variables; one for color names, one that maps color name variables to global semantic names (i.e. --primary-cta-color: var(--blue-50) or something), and maybe go so far as to add another that maps component-specific semantics to global specific semantics (i.e. --date-picker-hover-color: var(--primary-cta-color)).
That way, you can add something like
.theme-1 {
--primary-cta-color: var(--blue-50);
}
.theme-2 {
--primary-cta-color: var(--brown-40);
}
and / or @media (prefers-color-scheme: dark) {
.theme-1 {
--primary-color: var(--grey-30);
}
.theme-2 {
--primary-color: var(--brown-10);
}
}
as a purely hypothetical example. Slap the class name your user wants on the body tag, and you're good to go.A css property is set at a context, for example
body {color: blue}
div { color: green }
#alert {color: red}
https://codepen.io/bryanrasmussen/pen/PwNQyOm
this would be preferable to what was done variables because it is more straightforward. The dumb example of custom property using you highlight does not help make clearer code, nor does it help make css easier to understand, but I guess they were hoping people would see that custom properties inherit basically the same way that other properties inherit, except that there is this freaky :root context instead of using body.
obviously things can be complicated because only some properties inherit, but the claim holds. CSS properties are set by context.
It’s not a bad analogy, but how the spec intends it to work.
Either one is fine, the combination is bad.
<x>1<x>2<x>3</x></x></x> x > x > x {
--my-variable: 'my-value';
display: inline;
/* etc. */
}
It would be used by defining the value of another property as the value of the variable. Note the selectors don't have to match; in this case all x elements will have their content properties set to the --my-variable value but only the third-nested x element will have a --my-variable value set. x {
content: var(--my-variable);
}
Not that this is a particularly coherent example but hopefully you get the idea.It is possible to use style queries and some hacks (https://kizu.dev/self-modifying-variables/) to achieve this today, but that doesn't bring this closer to production, as Firefox still does not support them (but will be soon).
Also, this guy is calling HTML a programming language. Make of that what you will...
Pidgen is a type of language, too, but you wouldn't be writing Shakespeare in it.
There's nothing to be pedantic about HTML here, and it just seems so absolutely pointless to me that people try to find a way to be.
Embedded JS within HTML doesn't count here, as that's essentially no different than a linked script file.
To be fair, there are some exceptions to this; there are some very hacky and convoluted ways you might be able to get some programmatic behavior out of pure HTML (I remember hearing about a weird example in part of Wikipedia's codebase).
HTML literally means hypertext markup language. It's more like TeX or Markdown, in that it's used to store and represent data, not to manipulate it.
I'm not denying this but rather questioning why this means the document which specifies this is not a program. The previous sentences describe why it's not Turing-complete, which is moot to whether it's a programming language.
> HTML literally means hypertext markup language. It's more like TeX or Markdown, in that it's used to store and represent data, not to manipulate it.
I disagree that HTML is not used to manipulate data. Unless you mean to say that it doesn't manipulate it directly but I think that's also moot. My day job is to use HTML to build forms that are used to accept user input for data manipulations. It seems to me that I'm programming the browser to render the correct form and the language I'm using for the programming is HTML.
Besides, being used only to store and represent data does not seem to necessarily preclude it being a programming language. "Program" is a word that's used to describe a presentation of some kind. A wind ensemble might perform a "program" of pieces on concert night.
It's a set of instructions for a computer to execute. Hopefully that's not controversial. But isn't `<input type="text">` an instruction to render a text input?
If anything, I made it too specific by saying computer.
> is a mouse click not an instruction for a computer to execute?
If an SOP document—another example of a program—says to click a button on the screen, then of course that action is part of the instructions for a program. No computer needed, even; the instruction could be to stick my thumb up my nose, for all it matters.
markup language makes document
program does things. document presents info.
we use program to render document.
> programming language makes program
What makes a static .js file a program, not a document, and a static .html file a document, not a program?
> we use program to render document.
Is this like how node is a program that's used to render JS documents?
program does things. document presents info.
It's overly simplified to the point of being meaningless. A .js file is a document that presents information to me when I open it using a text editor. So is a .html file, for that matter. Something different happens when they're opened in a browser and, for that reason, they both seem to be programs as well.
program and document just are different things. (I gave a simplified definition). if they both are represented using text when creating, it doesn't make them the same. because some text is a programming language and can create program, and some text use markup language and can create document.
it's like humans and worms are carbon life, if you only look at that you can't tell difference between humans and worms. you need to look what kinds of cells are in them or even better what they do
It seems like you want to intentionally not understand this?
It seems like you are offering a poor response to a difference of opinion.
> if they both are represented using text when creating, it doesn't make them the same.
I think you misunderstood my point. You gave definitions that were overly simplistic, thinking they were accurate. I was just pointing out how inaccurate it is to say "program does thing. document presents info." Rather, more accurately, I'm pointing out that a file being one thing does not preclude it from being another (seeing as I generally agree that programs do things and documents present information).
You are taking the position that a document and a program are mutually exclusive and that's just not true. HTML files are executed as programs by a browser and displayed as a document by a text editor. JS files, too. I could go on. Of course, this opinion is not borne from willful ignorance of your opinion, but instead from my understanding of English.
> it's like humans and worms are carbon life, if you only look at that you can't tell difference between humans and worms. you need to look what kinds of cells are in them or even better what they do
You're arguing my point for me, with this paragraph. In the given analogy, "carbon life" is analogous to "program":
It's like, HTML and JS files are programs. If you can't tell the difference between HTML and JS files, you need to look at what text is in them or, even better, what they do.
Yes, thanks. That's pretty much what I'm saying. HTML and JS files are programs, much like how worms and humans are carbon-based organisms. They're otherwise wildly different and do different things. That genuinely seems obvious (to me) with no room for controversy. I'm not sure what reason there is for disagreement.
This reveals fundamental misunderstanding what is HTML and JS. "program" being different from "document" doesn't preclude some documents to have embedded programs within. however it doesn't turn a document into a program and doesn't mean markup language becomes programming language. there is still clear separation between hypertext markup and executable JS code
If I put that HTML inside of a <form> element, I could even get it to send the selections to a server of my choosing using the "action" attribute on said form (I may need to further instruct the browser to render a <button> or <input type="submit> inside the form or do some other fancy shenanigans). Put more useful options in the select and maybe some other input elements with some useful <label> elements and I might just have myself a graphical interface which people can use to submit information to me. But that's not right because it's just "present[ing] info", which just happens to be useful labels and inputs to in a form that will send the user-provided information to an external program; just a regular document, nothing special or "instructive" or "do[ing] things" about it. I hope I'm not laying it on too thick.
Seriously, though, if I didn't just describe a program that's executed by a browser then we have such fundamentally different ideas of what a "program" is that I might as well just concede that you're right, by whatever definition of the word you must be using.
[0] Every "Hello world!" program tutorial, which only instructs how to print that text to the screen before exiting, in every programming language ever is generally (and, IMO, reasonably) claimed to be a program, however rudimentary.
but this is not executing a program. this interpreting markup to render some data in some format. HTML is the same programming language as XML or Markdown or JPG or MIDI or WAV... so, not really a programming language. it's input for a program written using some programming language
sometimes presenting data and programming are conflated, for example postscript, but this is not HTML
> Put more useful options in the select and maybe some other input elements with some useful <label> elements and I might just have myself a graphical interface which people can use to submit information to me. But
Handling form submissions, handling displaying select boxes etc, is all result of executing program that is browser itself. The input for that program is hypertext markup by webmaster.
(Running embedded JS however is executing a program by webmaster.)
I think trying to present markup as programming is very artificial and does not correspond to real world.
Yes, it's interpreting markup to render some data in some format but that does not preclude such interpretation from being the execution of a program.
> sometimes presenting data and programming are conflated
My point is that executing a program is not mutually exclusive with presenting data. I am not conflating these terms but rather the opposite; I am pointing out that they are separate concepts which do not necessarily conflict with each other.
> Handling form submissions, handling displaying select boxes etc, is all result of executing program that is browser itself. The input for that program is hypertext markup
Right, that "hypertext markup" is a program for the browser (another program) to execute. That seems like an accurate use of English. If this is where we draw the line then JS must not be a programming language because it's just some kind of "script text" that is the input for some other real program.
> Running embedded JS however is executing a program by webmaster.
I understand this is your perspective but you haven't drawn a clear line separating this from the execution of an HTML program. Running plain HTML in a browser, consisting strictly of the necessary components of a valid HTML document, is also executing a program (webmaster isn't necessary).
HTML is one of the languages I use when I am programming. In the sense, I really struggle to see the argument that it isn't a programming language, unless someone is using a very precise definition of "programming language" that I'm not privy to. There's a bunch of well-defined stuff it _isn't_ (e.g. Turing-complete), and a bunch of well-defined stuff that it is (e.g. declarative, or a markup language), but as far as I can tell there's no better definition of "programming language" than "language used for programming", and it certainly seems to fit that bill.
The only requirements is that it compiles into a set of instructions which computers (or sewing machines, etc.) know how to read and execute into a predictable (preferably desired) outcome.
A programming language does not need to be Turing complete to be a programming language.
Although... while this seems like heaven at first, seeing this being done in practice, it is hell. It's just people don't know they are in hell. They got used to it.
You can either pay a web developer to update your fully static site once a year, or you can pay them five times a year to clean up your Wordpress install when it inevitably gets popped because that one mailback form plugin you demanded... you know the one that has never received a single non-spam submission... hasn't been updated in ten years... and also you're too cheap to pay someone to maintain your Wordpress site because "why would I do that the site is finished?"
But I have dozens of websites I built and am still building today in the way described and it works just as well for me. As a single developer with "simple" websites it's just great to have so little mental load when fixing some small things.
Admittedly I have a small script to upload stuff via ftp (if ssh/rsync is not available), so no FileZilla anymore :)
At the moment I’m still mainly fixing and customizing the theme, but I expect that once I actually start blogging instead of fixing the theme and learning Hugo, GitHub actions would make sense again.
I suggest you use a platform like justblogged.com.
Shameless plug, yes I built it.
Meh. That's over-engineered[1] /s :-)
--------------------
[1] I have a bash script that produces the site from markdown snippets, commits it to a repo and the VPS pulls master periodically.
CSS grid and subgrid, nesting, variables, container queries, css layers…
In 2025 it’s a pleasure to work with. Props to the amazing people involved in pushing the standards forward.
Then again, writing stylesheets is still one of those things where, if you're not careful, everything spirals out of control. Often I'll make changes and wonder why nothing's happening and realize something was overridden by another rule somewhere, or I was mixing up two properties, or some other silly thing...
I also find it's a bit awkward to write var(--foo) every time... I wish I could just write --foo... I suppose there's a grammar issue somewhere, or maybe it would have increased the complexity of implementations of CSS.
It doesn't have to be this way; just write your CSS using Inverted Triangle CSS (ITCSS) [1] and these issues go away.
E.g: aspect-ratio: attr(width px) / attr(height px);
I'm not a CSS expert but being able to do so much with it before having to reach for JS is fantastic.
And with Blazor, some of that JS sprinkle isn't even needed anymore.
I am not so sure about PHP, but I think the intent is more "do it in the backend where possible" which i agree with.
And it made me want to claw my eyes out.
Browser idiosyncrasies, horrendous security vulnerabilities, the blood sacrifices to do basic things with CSS, trying to debug in IE, the daily “maybe Flash isn’t that bad” introspection.
There are many good things about this world.
2005 web dev is not among them.
...
> There are many good things about this world. 2005 web dev is not among them.
Maybe, but the 2005 process will work better now, because the current process was started as a way to paper over all those
> Browser idiosyncrasies, horrendous security vulnerabilities, the blood sacrifices to do basic things with CSS,
Now that those things are smaller issues, "Write JS, copy it to the server" is not so stupid. Especially if you've got mostly web components.
Go and vertically center a div in whatever way you see fit.
New tech makes the old process more viable, not less.
<p><font face="font">Your text here</font></p>
Looks way better than:
<p style="font-family: 'font', sans-serif;"></p>
to me.
(Again, not trying to criticize, just trying to understand.)
Web components = custom elements
:shrug: