ert

Brands and billboards: Will marketers rethink outdoor advertising?

The Mumbai billboard crash has shaken up the advertising industry. Will brands be reluctant to spend on the outdoor medium now? 




ert

‘It is time we manufacture vertical TV sets’ says Ram Madhvani

Lights, Camera, action: Ace ad film maker and movie director on creative trends and changing technology




ert

Property matters

The National Housing Bank has issued guidelines to housing finance companies on stamp duty and other charges, reports K.A. Martin




ert

Delay in handing over property

Your property-related legal queries answered by S.C. RAGHURAM, Partner, RANK Associates, a Chennai-based law firm




ert

Taxing time for property owners

The ‘online payment only’ rule for property tax should be implemented gradually, feels K. Sukumaran




ert

Device which can convert any normal bed into a step-down ICU to be deployed in six States 

This will be deployed in public healthcare systems across Karnataka, Tamil Nadu, Andhra Pradesh, Madhya Pradesh, Odisha, and Sikkim




ert

Chambal Fertilisers & Chemicals Ltd. - Revised disclosures under Reg. 31(1) and 31(2) of SEBI (SAST) Regulations, 2011




ert

Structural and thermodynamic properties of the Li6PS5Cl solid electrolyte using first-principles calculations

J. Mater. Chem. A, 2024, Accepted Manuscript
DOI: 10.1039/D4TA05159A, Paper
Tarek Ayadi, Maylise Nastar, Fabien Bruneval
We perform static and dynamic ab initio simulations to investigate the structural and the thermodynamic properties of Li6PS5Cl, a solid electrolyte actively considered for solid-state batteries. Our simulations account for...
The content of this RSS Feed (c) The Royal Society of Chemistry




ert

Tuning the acidity and textural properties of polyethyleneimine-supported adsorbents for enhanced economical CO2 capture

J. Mater. Chem. A, 2024, 12,30309-30317
DOI: 10.1039/D4TA05215C, Paper
Bitan Ray, Sathyapal R. Churipard, Arjun Cherevotan, Diku Raj Deka, Devender Goud, Harishankar Kopperi, Sebastian C. Peter
The acidity and textural properties of polyethyleneimine-supported adsorbents are tuned to enhance the capture of carbon dioxide in an economical way.
The content of this RSS Feed (c) The Royal Society of Chemistry




ert

Characterization of pitch carbon coating properties affecting the electrochemical behavior of silicon nanoparticle lithium-ion battery anodes

J. Mater. Chem. A, 2024, 12,30465-30475
DOI: 10.1039/D4TA04478A, Paper
Zoey Huey, Maxwell C. Schulze, G. Michael Carroll, Chaiwat Engtrakul, Chun-Sheng Jiang, Steven C. DeCaluwe, Bertrand J. Tremolet de Villers, Sang-Don Han
700 °C is the optimal heat treatment temperature for pitch-coated silicon electrodes. Both the amorphous carbon/pitch and silicon are active materials but store Li+ ions through different ion storage mechanisms and contribute to overall performance.
The content of this RSS Feed (c) The Royal Society of Chemistry




ert

Microphase-separation-induced polyzwitterionic ionogel with tough, highly conductive, self-healing and shape–memory properties for wearable electrical devices

J. Mater. Chem. A, 2024, 12,30618-30628
DOI: 10.1039/D4TA04228J, Paper
Guang Zeng, Wenshuo Gao, Weicheng Qiu, Guanling Li, Shousen Chen, Xin He, Guoxing Sun, Weijia Yang, Yue Xin
A polyzwitterionic ionogel with a phase separation structure was designed to achieve a balance between mechanical robustness and ionic conductivity. This design holds immense potential for applications in wearable sensors.
The content of this RSS Feed (c) The Royal Society of Chemistry




ert

The composition/field-induced octahedral tilt, domain switching and improved piezoelectric properties of BF-BT ceramics during phase transition

J. Mater. Chem. A, 2024, 12,30420-30428
DOI: 10.1039/D4TA03949A, Paper
Jinyu Chen, Chao Chen, Chong Zhao, Na Tu, Yunjing Chen, Xin Nie, Xiaokun Huang, Jun-Ming Liu, Xiangping Jiang
The structural mechanism underlying the high piezoelectric activity of BF-BT was elucidated from the aspects of phase structure, domain dynamics, and octahedral torsion under an electric field.
The content of this RSS Feed (c) The Royal Society of Chemistry




ert

Tailoring the electrocatalytic properties of novel microwave synthesized CuNd(2−x)GdxO4 nanoparticles for efficient total water splitting in alkaline media

J. Mater. Chem. A, 2024, 12,30850-30861
DOI: 10.1039/D4TA05919K, Paper
Anto Priyanka E, Sreenivasan Nagappan, J. Judith Vijaya, Angappan Sankaramahalingam, Subrata Kundu
CuNd(2−x)GdxO4 nanoparticles synthesized via microwave method as efficient OER and HER catalysts require low overpotentials exhibiting remarkable stability. Gd doping enhances charge transfer leading to optimized electrocatalysis.
The content of this RSS Feed (c) The Royal Society of Chemistry




ert

Vertical Macroporous Chitosan Aerogel Adsorbents for Simple and Efficient Enhancement of Atmospheric Water Harvesting and Air Dehumidification

J. Mater. Chem. A, 2024, Accepted Manuscript
DOI: 10.1039/D4TA07005D, Paper
Zhiguang Guo, Changhui Fu, Yuxuan He, Anhui Yu, Guangyi Tian, Danyan Zhan, Huimin Zhang
Adsorption-based atmospheric water harvesting (SAWH) has become one of the effective methods to extract water from the air in arid regions due to its high efficiency and low energy consumption....
The content of this RSS Feed (c) The Royal Society of Chemistry




ert

Top Katsubet Casino Entertainment Available 24/7

  Table of Contents Katsubet Casino Facilitation of business dealings Katsubet Casino Bonus Activation Guide Casino original bonus policy Katsubet Casino The slot machines are the most exciting part of the casinoonline Katsubet Casino games huge popularity in Australia . Because having access to the best and most varied games naturally generates rivalry with other […]




ert

Matrimony Certificate Process and Via the internet Marriage Firm

Marriage certificate procedure Whether you are looking for a long term relationship or maybe a marriage, it is crucial to know the legal techniques online brides and the way to apply for a marital relationship certificate. This doc will function as your resistant of valid matrimony and will provide you with a number of other […]




ert

Avg Cleaner Expert Apk Assessment

avg more refined pro apk is a smart system supervision and marketing tool that has been installed simply by almost 60 million users. It helps you avoid lagging and remove junk files, and optimize photographs so you can enjoy your smart phone more. In addition, it helps you conserve battery power, and it will find […]




ert

The very best VDR pertaining to Startups

Using VDRs to store and share documents makes the due diligence procedure easier for all those stakeholders. Additionally, it can save money and time by eliminating the need to send physical documents to multiple locations or discuss with a team. Additionally , a VDR can allow all users to access your data from any device, […]




ert

Commercial Property Data Organizing

Organizing business property info enables organization users to get the observations needed to generate defendable short and long term commercial proper property decisions. While it might sound like an arduous process, CRE specialists can streamline the procedure with the help of data platforms that provide foundational data sets in a single easy-to-navigate dashboard. These types […]




ert

Info Room Solutions and Their Uses in the Property, Manufacturing, and Fundraising Industries

Data space technologies enable companies to exchange documents safely, whether it is intended for collaboration over a project or perhaps due diligence. They are really a digital variety of the physical rooms exactly where sensitive paperwork used to be stored. Nevertheless , these on line spots offer a much more features to facilitate cooperation and […]




ert

Jan Dhan Account Holders Alert: Do THIS Else Your Saving Account May Get Closed

As per the Government of India, around 53 crore people were brought into the formal banking system through the opening of Jan Dhan Accounts.




ert

Swiggy Stock Market Listing Today: Will Investors Make Money From Swiggy IPO? Check What Expert Says

Shivani Nyati, Head of Wealth at Swastika Investmart Ltd said that a cautious approach needed for the Swiggy IPO. 




ert

Zeenat’s Mantras, women in advertising and the Awe Economy

Day two of advertising festival Goafest, saw Zeenat Aman share how she adapted to the mobile screen, the industry debating gender stereotyping in ads and more




ert

Gautam Adani overtakes Ambani to become Asia’s richest person again

Adani with a net worth of $111 billion is now ranked as the eleventh richest in the world, according to the Bloomberg Billionaires Index.




ert

GOAT will be one of the most profitable for us, says Suresh Kalpathi, AGS Entertainment

AGS Entertainment is doing another movie with Pradeep Ranganathan and also produced by the production house




ert

Dua Lipa on her upcoming concert in India: Can’t wait to see you again

The Grammy winner, known for songs such as "Levitating", "Houdini", and "Dance The Night", shared a post on Instagram expressing her excitement for the upcoming show




ert

Mercedes Benz to come up with traffic alert system




ert

Mobile banking will overtake net banking: HDFC

The bank reported 17.46 lakh mobile transactions worth over Rs. 5,686 crore, making it the market leader in the segment.




ert

Watch: Demo of hydrogen-electric powered vertical take-off and landing aircraft

Hyderabad-based advanced air mobility startup BluJ Aero conducted a flight demonstration of its VTOL aircraft




ert

Climate experts worry about Donald Trump’s re-election impact

Climate experts anxious about American commitment to carbon mitigation efforts, particularly the Trump campaign’s espousal for fracking and distrust of scientific consensus on the impacts of greenhouse gas warming




ert

Invert sugar: The unsung hero of sweetness

Derived through hydrolysis, it is sweeter and also more soluble than regular sugar, making it a preferred choice for various culinary creations




ert

Bank Nifty prediction today – Oct 30, 2024: Intraday trend uncertain at the moment

The key levels for Bank Nifty futures are 51,200 and 52,700




ert

F&O Tracker: Outlook uncertain for index futures

Nifty futures posted a marginal gain of 0.2 per cent and Bank Nifty futures appreciated 1.5 per cent over the past week




ert

Bank Nifty Prediction today – Nov 6, 2024: Intraday trend uncertain, stay out

Bank Nifty futures is trading between key levels at 52,000 and 52,800




ert

Natural gas futures: Uncertainty prevails

Traders need to wait for strong cues about next leg of trend




ert

Tech Query: What is the outlook for TVS Holdings, Gujarat State Fertilizers & Chemicals (GSFC), Ideaforge Technology and Niyogin Fintech?

We zoom in on the prospects of TVS Holdings, as also the prospects of three other stocks — Gujarat State Fertilizers & Chemicals (GSFC), Ideaforge Technology and Niyogin Fintech




ert

Two options for using custom properties

Recently I interviewed Stefan Judis for my upcoming book. We discussed CSS custom properties, and something interesting happened.

We had a period of a few minutes where we were talking past one another, because, as it turns out, we have completely opposite ideas about the use of CSS custom properties. I had never considered his approach, and I found it interesting enough to write this quick post.

Option 1

Take several site components, each with their own link and hover/focus colours. We want to use custom properties for those colours. Exactly how do we do that?

Before my discussion with Stefan that wasn’t even a question for me. I would do this:

.component1 {
	--linkcolor: red;
	--hovercolor: blue;
}

.component2 {
	--linkcolor: purple;
	--hovercolor: cyan;
}

a {
	color: var(--linkcolor);
}

a:hover,a:focus {
	color: var(--hovercolor)
}

I set the normal and hover/focus colour as a custom property, and leave the definition of those properties to the component the link appears in. The first and second component each define different colours, which are deployed in the correct syntax. Everything works and all’s well with the world.

As far as I can see now this is the default way of using CSS custom properties. I wasn’t even aware that another possibility existed.

Option 2

Stefan surprised me by doing almost the complete opposite. He uses only a single variable and changes its value where necessary:

.component1 {
	--componentcolor: red;
}

.component1 :is(a:hover,a:focus) {
	--componentcolor: blue;
}
	
.component2 {
	--componentcolor: purple;
}

.component2 :is(a:hover,a:focus) {
	--componentcolor: cyan;
}
	
a {
	color: var(--componentcolor)		
}

At first I was confused. Why would you do this? What’s the added value of the custom property? Couldn’t you just have entered the colour values in the component styles without using custom properties at all?

Well, yes, you could. But that’s not Stefan’s point.

The point

In practice, component definitions have way more styles than just colours. There’s a bunch of box-model properties, maybe a display, and possibly text styling instructions. In any case, a lot of lines of CSS.

If you use custom properties only for those CSS properties that will change you give future CSS developers a much better and quicker insight in how your component works. If the definition uses a custom property that means the property may change in some circumstances. If it uses a fixed definition you know it’s a constant.

Suppose you encounter this component definition in a codebase you just inherited:

.component {
	--color: red;
	--background: blue
	--layout: flex;
	--padding: 1em;
	--borderWidth: 0.3em;
	display: var(--layout);
	color: var(--color);
	background: var(--background);
	padding: var(--padding);
	border: var(--borderWidth) solid black;
	margin: 10px;
	border-radius: 2em;
	grid-template-columns: repeat(3,1fr);
	flex-wrap: wrap;
}

Now you essentially found a definition file. Not only do you see the component’s default styles, you also see what might change and what will not. For instance, because the margin and border-radius are hard-coded you know they are never changed. In the case of the border, only the width changes, not the style or the colour. Most other properties can change.

The use of display: var(--layout) is particularly revealing. Apparently something somewhere changes the component’s layout from grid to flexbox. Also, if it’s a grid it has three equal columns, while if it’s a flexbox it allows wrapping. This suggests that the flexbox layout is used on narrower screens, switching to a grid layout on wider screens.

Where does the flexbox change to a grid? As a newbie to this codebase you don’t know, but you can simply search for --layout: grid and you’ll find it, probably neatly tucked away in a media query somewhere. Maybe there is a basic layout as well, which uses neither flexbox nor grid? Search for --layout: block and you’ll know.

Thus, this way of using custom properties is excellently suited for making readable code bases that you can turn over to other CSS developers. They immediately know what changes and what doesn’t.

Teaching aid?

There’s another potential benefit as well: this way of using custom properties, which are essentially variables, aligns much more with JavaScript’s use of variables. You set an important variable at the start of your code, and change it later on if necessary. This is what you do in JavaScript all the time.

Thus this option may be better suited to teaching CSS to JavaScripters, which remains one of my preoccupations due to the upcoming book.

Picking an option

Which option should you pick? That’s partly a matter of personal preference. Since the second option is still fairly new to me, and I rarely work on large projects, I am still feeling my way around it. Right at this moment I prefer the first way because I’m used to it. But that might change, given some extra time.

Still, I think Stefan is on to something. I think that his option is very useful in large codebases that can be inherited by other developers. I think it deserves careful consideration.



  • CSS for JavaScripters

ert

Inherit, initial, unset, revert

Today we’re going to take a quick look at a few special CSS keywords you can use on any CSS property: inherit, initial, revert, and unset. Also, we will ask where and when to use them to the greatest effect, and if we need more of those keywords.

The first three were defined in the Cascading Level 3 spec, while revert was added in Cascading Level 4. Despite 4 still being in draft revert is already supported. See also the MDN revert page, Chris Coyier’s page, and my test page

inherit

The inherit keyword explicitly tells an element that it inherits the value for this declaration from its parent. Let’s take this example:

.my-div {
	margin: inherit;
}

.my-div a {
	color: inherit;
}

The second declaration is easiest to explain, and sometimes actually useful. It says that the link colour in the div should be the same as the text colour. The div has a text colour. It’s not specified here, but because color is inherited by default the div gets the text color of its parent. Let’s say it’s black.

Links usually have a different colour. As a CSS programmer you frequently set it, and even if you don’t browsers automatically make it blue for you. Here, however, we explicitly tell the browsers that the link colour should be inherited from its parent, the div. In our example links become black.

(Is this a good idea? Occasionally. But if you remove the colour difference between links and main text, make sure your links are underlined. Your users will thank you.)

Now let’s look at the margin: inherit. Normally margins don’t inherit, and for good reason. The fact that an element has margin-left: 10% does not mean all of its descendents should also get that margin. In fact, you most likely don’t want that. Margins are set on a per-case basis.

This declaration tells the div to use the margin specified on its parent, however. This is an odd thing to specify, and I never saw a practical use case in the wild. Still CSS, being ridiculously powerful, allows it.

In any case, that’s how the inherit keyword works. Using it for font sizes or colours may occasionally be a good idea. In other contexts - rarely.

And keep the difference between inheriting and non-inheriting properties in mind. It’s going to be important later on.

initial

The initial keywords sets the property back to its initial value. This is the value specified in the W3C specification for that property.

Initial values from the spec are a bit of a mixed bag. Some make sense, others don’t, really. float: none and background-color: transparent are examples of the first category. Of course an element does not have a background colour without you specifying one, nor does it float automatically.

Others are historically determined, such as background-repeat: repeat. Back in the Stone Age before CSS all background images repeated, and the CSS1 specification naturally copied this behaviour.

Still others are essentially arbitrary, such as display: inline. Why did W3C opt for inline instead of block? I don’t know, and it doesn’t really matter any more. They had to decide on an initial value, and while inline is somewhat strange, block would be equally strange.

In any case, the initial keyword makes the property revert to this initial value from the specification, whether that makes sense or not.

unset

When we get to the unset value the distinction between inheriting and non-inheriting properties becomes important. unset has a different effect on them.

  • If a property is normally inherited, unset means inherit.
  • If a property is normally not inherited, unset means initial.

revert

revert, the newest of these keywords, also distinguishes between inheriting and non-inheriting properties.

  • If a property is normally inherited, revert means inherit.
  • If a property is normally not inherited, revert reverts to the value specified in the browser style sheet.

all

Finally, we should treat all. It is not a value but a property, or rather, the collection of all CSS properties on an element. It only takes one of the keywords we discussed, and allows you to apply that keyword to all CSS properties. For instance:

.my-div {
	all: initial;
}

Now all CSS properties on the div are set to initial.

Examples

The reaction of my test page to setting the display of all elements to the four keywords is instructive. My test script sets the following style:

body * {
	display: [inherit | initial | unset | revert] !important;
}

The elements react as follows:

  • display: inherit: all elements now inherit their display value from the body. Since the body has display: block all elements get that value, whether that makes sense or not.
  • display: initial: the initial value of display is inline. Therefore all elements get that value, whether that makes sense or not.
  • display: unset: display does not inherit. Therefore this behaves as initial and all elements get display: inline.
  • display: revert: display does not inherit. Therefore the defaults of the browser style sheet are restored, and each element gets its proper display — except for the dl, which I had given a display: grid. This value is now supplanted by the browser-provided block.

Unfortunately the same test page also contains a riddle I don’t understand the behaviour of <button>s when I set color to the four keywords:

  • color: inherit: all elements, including <button>s, now inherit their colour from the body, which is blue. So all text becomes blue.
  • color: initial: since the initial value of color is black, all elements, including <button>s, become black.
  • color: unset: color inherits. Therefore this behaves as inherit and all elements, including <button>s, become blue.
  • color: revert: This is the weird one. All elements become blue, except for <button>s, which become black. I don’t understand why. Since colors inherit, I expected revert to work as inherit and the buttons to also become blue. But apparently the browser style sheet of button {color: black} (more complicated in practice) is given precedence. Yes, revert should remove author styles (the ones we write), and that would cause the black from the browser style sheet to be applied, but only if a property does not inherit — and color does. I don’t know why the browser style sheet is given precedence in this case. So I’m going to cop out and say form elements are weird.

Practical use: almost none

The purpose of both unset and revert is to wipe the slate clean and return to the initial and the browser styles, respectively — except when the property inherits; in that case, inheritance is still respected. initial, meanwhile, wipes the slate even cleaner by also reverting inheriting properties to their initial values.

This would be useful when you create components that should not be influenced by styles defined elsewhere on the page. Wipe the slate clean, start styling from zero. That would help modularisation.

But that’s not how these keywords work. We don’t want to revert to the initial styles (which are sometimes plain weird) but to the browser style sheet. unset comes closest, but it doesn’t touch inherited styles, so it only does half of what we want.

So right now these keywords are useless — except for inherit in a few specific situations usually having to do with font sizes and colours.

New keyword: default

Chris Coyier argues we need a new value which he calls default. It reverts to the browser style sheet in all cases, even for inherited properties. Thus it is a stronger version of revert. I agree. This keyword would be actually useful. For instance:

.my-component,.my-component * {
	all: default;
	font-size: inherit;
	font-family: inherit;
	color: inherit;
}

Now we have a component that’s wiped clean, except that we decide to keep the fonts and colour of the main page. The rest is a blank slate that we can style as we like. That would be a massive boon to modularisation.

New keyword: cascade

For years now I have had the feeling that we need yet another keyword, which I’ll call cascade for now. It would mean “take the previous value in the cascade and apply it here.” For instance:

.my-component h2 {
	font-size: 24px;
}

.my-other-component h2 {
	font-size: 3em;
}

h2#specialCase {
	font-size: clamp(1vw,cascade,3vw)
}

In this (slightly contrived) example I want to clamp the font-size of a special h2 between 1vw and 3vw, with the preferred value being the one defined for the component I’m working in. Here, cascade would mean: take the value the cascade would deliver if this rule didn’t exist. This would make the clamped font size use either 24px or 3em as its preferred value, depending on which component we’re in.

The problem with this example is that it could also use custom properties. Just set --h2size to either 24px or 3em, use it in the clamp, and you’re done.

.my-component h2 {
	--h2size: 24px;
	font-size: var(--h2size);
}

.my-other-component h2 {
	--h2size: 3em;
	font-size: var(--h2size);
}

h2#specialCase {
	font-size: clamp(1vw,var(--h2size),3vw)
}

Still, this is but the latest example I created. I have had this thought many, many times, but because I didn’t keep track of my use cases I’m not sure if all of them could be served by custom properties.

Also, suppose you inherit a very messy CSS code base with dozens of components written at various skill levels. In that case adding custom properties to all components might be impractical, and the cascade keyword might help.

Anyway, I barely managed to convince myself, so professional standard writers will certainly not be impressed. Still, I thought I’d throw it out here to see if anyone else has a use case for cascade that cannot be solved with custom properties.



  • CSS for JavaScripters

ert

Custom properties and @property

You’re reading a failed article. I hoped to write about @property and how it is useful for extending CSS inheritance considerably in many different circumstances. Alas, I failed. @property turns out to be very useful for font sizes, but does not even approach the general applicability I hoped for.

Grandparent-inheriting

It all started when I commented on what I thought was an interesting but theoretical idea by Lea Verou: what if elements could inherit the font size of not their parent, but their grandparent? Something like this:

div.grandparent {
	/* font-size could be anything */
}

div.parent {
	font-size: 0.4em;
}

div.child {
	font-size: [inherit from grandparent in some sort of way];
	font-size: [yes, you could do 2.5em to restore the grandparent's font size];
	font-size: [but that's not inheriting, it's just reversing a calculation];
	font-size: [and it will not work if the parent's font size is also unknown];
}

Lea told me this wasn’t a vague idea, but something that can be done right now. I was quite surprised — and I assume many of my readers are as well — and asked for more information. So she wrote Inherit ancestor font-size, for fun and profit, where she explained how the new Houdini @property can be used to do this.

This was seriously cool. Also, I picked up a few interesting bits about how CSS custom properties and Houdini @property work. I decided to explain these tricky bits in simple terms — mostly because I know that by writing an explanation I myself will understand them better — and to suggest other possibilities for using Lea’s idea.

Alas, that last objective is where I failed. Lea’s idea can only be used for font sizes. That’s an important use case, but I had hoped for more. The reasons why it doesn’t work elsewhere are instructive, though.

Tokens and values

Let’s consider CSS custom properties. What if we store the grandparent’s font size in a custom property and use that in the child?

div.grandparent {
	/* font-size could be anything */
	--myFontSize: 1em;
}

div.parent {
	font-size: 0.4em;
}

div.child {
	font-size: var(--myFontSize);
	/* hey, that's the grandparent's font size, isn't it? */
}

This does not work. The child will have the same font size as the parent, and ignore the grandparent. In order to understand why we need to understand how custom properties work. What does this line of CSS do?

--myFontSize: 1em;

It sets a custom property that we can use later. Well duh.

Sure. But what value does this custom property have?

... errr ... 1em?

Nope. The answer is: none. That’s why the code example doesn’t work.

When they are defined, custom properties do not have a value or a type. All that you ordered the browsers to do is to store a token in the variable --myFontSize.

This took me a while to wrap my head around, so let’s go a bit deeper. What is a token? Let’s briefly switch to JavaScript to explain.

let myVar = 10;

What’s the value of myVar in this line? I do not mean: what value is stored in the variable myVar, but: what value does the character sequence myVar have in that line of code? And what type?

Well, none. Duh. It’s not a variable or value, it’s just a token that the JavaScript engine interprets as “allow me to access and change a specific variable” whenever you type it.

CSS custom properties also hold such tokens. They do not have any intrinsic meaning. Instead, they acquire meaning when they are interpreted by the CSS engine in a certain context, just as the myVar token is in the JavaScript example.

So the CSS custom property contains the token 1em without any value, without any type, without any meaning — as yet.

You can use pretty any bunch of characters in a custom property definition. Browsers make no assumptions about their validity or usefulness because they don’t yet know what you want to do with the token. So this, too, is a perfectly fine CSS custom property:

--myEgoTrip: ppk;

Browsers shrug, create the custom property, and store the indicated token. The fact that ppk is invalid in all CSS contexts is irrelevant: we haven’t tried to use it yet.

It’s when you actually use the custom property that values and types are assigned. So let’s use it:

background-color: var(--myEgoTrip);

Now the CSS parser takes the tokens we defined earlier and replaces the custom property with them:

background-color: ppk;

And only NOW the tokens are read and intrepreted. In this case that results in an error: ppk is not a valid value for background-color. So the CSS declaration as a whole is invalid and nothing happens — well, technically it gets the unset value, but the net result is the same. The custom property itself is still perfectly valid, though.

The same happens in our original code example:

div.grandparent {
	/* font-size could be anything */
	--myFontSize: 1em; /* just a token; no value, no meaning */
}

div.parent {
	font-size: 0.4em;
}

div.child {
	font-size: var(--myFontSize);
	/* becomes */
	font-size: 1em; 
	/* hey, this is valid CSS! */
	/* Right, you obviously want the font size to be the same as the parent's */
	/* Sure thing, here you go */
}

In div.child he tokens are read and interpreted by the CSS parser. This results in a declaration font-size: 1em;. This is perfectly valid CSS, and the browsers duly note that the font size of this element should be 1em.

font-size: 1em is relative. To what? Well, to the parent’s font size, of course. Duh. That’s how CSS font-size works.

So now the font size of the child becomes the same as its parent’s, and browsers will proudly display the child element’s text in the same font size as the parent element’s while ignoring the grandparent.

This is not what we wanted to achieve, though. We want the grandparent’s font size. Custom properties — by themselves — don’t do what we want. We have to find another solution.

@property

Lea’s article explains that other solution. We have to use the Houdini @property rule.

@property --myFontSize {
	syntax: "<length>";
	initial-value: 0;
	inherits: true;
}

div {
	border: 1px solid;
	padding: 1em;
}

div.grandparent {
	/* font-size could be anything */
	--myFontSize: 1em;
}

div.parent {
	font-size: 0.4em;
}

div.child {
	font-size: var(--myFontSize);
}

Now it works. Wut? Yep — though only in Chrome so far.

This is the grandparent
This is the parent
This is the child

What black magic is this?

Adding the @property rule changes the custom property --myFontSize from a bunch of tokens without meaning to an actual value. Moreover, this value is calculated in the context it is defined in — the grandfather — so that the 1em value now means 100% of the font size of the grandfather. When we use it in the child it still has this value, and therefore the child gets the same font size as the grandfather, which is exactly what we want to achieve.

(The variable uses a value from the context it’s defined in, and not the context it’s executed in. If, like me, you have a grounding in basic JavaScript you may hear “closures!” in the back of your mind. While they are not the same, and you shouldn’t take this apparent equivalency too far, this notion still helped me understand. Maybe it’ll help you as well.)

Unfortunately I do not quite understand what I’m doing here, though I can assure you the code snippet works in Chrome — and will likely work in the other browsers once they support @property.

Misson completed — just don’t ask me how.

Syntax

You have to get the definition right. You need all three lines in the @property rule. See also the specification and the MDN page.

@property --myFontSize {
	syntax: "<length>";
	initial-value: 0;
	inherits: true;
}

The syntax property tells browsers what kind of property it is and makes parsing it easier. Here is the list of possible values for syntax, and in 99% of the cases one of these values is what you need.

You could also create your own syntax, e.g.

syntax: "ppk | <length>"

Now the ppk keyword and any sort of length is allowed as a value.

Note that percentages are not lengths — one of the many things I found out during the writing of this article. Still, they are so common that a special value for “length that may be a percentage or may be calculated using percentages” was created:

syntax: "<length-percentage>"

Finally, one special case you need to know about is this one:

syntax: "*"

MDN calls this a universal selector, but it isn’t, really. Instead, it means “I don’t know what syntax we’re going to use” and it tells browsers not to attempt to interpret the custom property. In our case that would be counterproductive: we definitely want the 1em to be interpreted. So our example doesn’t work with syntax: "*".

initial-value and inherits

An initial-value property is required for any syntax value that is not a *. Here that’s simple: just give it an initial value of 0 — or 16px, or any absolute value. The value doesn’t really matter since we’re going to overrule it anyway. Still, a relative value such as 1em is not allowed: browsers don’t know what the 1em would be relative to and reject it as an initial value.

Finally, inherits: true specifies that the custom property value can be inherited. We definitely want the computed 1em value to be inherited by the child — that’s the entire point of this experiment. So we carefully set this flag to true.

Other use cases

So far this article merely rehashed parts of Lea’s. Since I’m not in the habit of rehashing other people’s articles my original plan was to add at least one other use case. Alas, I failed, though Lea was kind enough to explain why each of my ideas fails.

Percentage of what?

Could we grandfather-inherit percentual margins and paddings? They are relative to the width of the parent of the element you define them on, and I was wondering if it might be useful to send the grandparent’s margin on to the child just like the font size. Something like this:

@property --myMargin {
	syntax: "<length-percentage>";
	initial-value: 0;
	inherits: true;
}

div.grandparent {
	--myMargin: 25%;
	margin-left: var(--myMargin);
}

div.parent {
	font-size: 0.4em;
}

div.child {
	margin-left: var(--myMargin);
	/* should now be 25% of the width of the grandfather's parent */
	/* but isn't */
}

Alas, this does not work. Browsers cannot resolve the 25% in the context of the grandparent, as they did with the 1em, because they don’t know what to do.

The most important trick for using percentages in CSS is to always ask yourself: “percentage of WHAT?”

That’s exactly what browsers do when they encounter this @property definition. 25% of what? The parent’s font size? Or the parent’s width? (This is the correct answer, but browsers have no way of knowing that.) Or maybe the width of the element itself, for use in background-position?

Since browsers cannot figure out what the percentage is relative to they do nothing: the custom property gets the initial value of 0 and the grandfather-inheritance fails.

Colours

Another idea I had was using this trick for the grandfather’s text colour. What if we store currentColor, which always has the value of the element’s text colour, and send it on to the grandchild? Something like this:

@property --myColor {
	syntax: "<color>";
	initial-value: black;
	inherits: true;
}

div.grandparent {
	/* color unknown */
	--myColor: currentColor;
}

div.parent {
	color: red;
}

div.child {
	color: var(--myColor);
	/* should now have the same color as the grandfather */
	/* but doesn't */
}

Alas, this does not work either. When the @property blocks are evaluated, and 1em is calculated, currentColor specifically is not touched because it is used as an initial (default) value for some inherited SVG and CSS properties such as fill. Unfortunately I do not fully understand what’s going on, but Tab says this behaviour is necessary, so it is.

Pity, but such is life. Especially when you’re working with new CSS functionalities.

Conclusion

So I tried to find more possbilities for using Lea’s trick, but failed. Relative units are fairly sparse, especially when you leave percentages out of the equation. em and related units such as rem are the only ones, as far as I can see.

So we’re left with a very useful trick for font sizes. You should use it when you need it (bearing in mind that right now it’s only supported in Chromium-based browsers), but extending it to other declarations is not possible at the moment.

Many thanks to Lea Verou and Tab Atkins for reviewing and correcting an earlier draft of this article.



  • CSS for JavaScripters

ert

Man, wife bludgeon mother to death over property row




ert

Payasam lovers in Thiruvananthapuram are spoilt for choice with shops selling the dessert throughout the year

Outlets selling different kinds of payasam have mushroomed in the city




ert

Zonal misclassification: Government waives ₹240 crore property tax penalty levied by BBMP

Penalty was levied for zonal misclassification while paying property tax online




ert

Director Vassishta: The audience can expect to see Chiranjeevi in an entertaining fantasy film like ‘Jagadeka Veerudu Athiloka Sundari’

Director Vassishta opens up on his next film starring Chiranjeevi and says it will be a fantasy entertainer, steeped in visual effects, in which the superstar will play a mature character befitting his stature and age




ert

Explore corals at Havelock island with CGH Earth’s latest property, Tilar Siro

We check into an eco resort set on one of the largest islands in the Andaman chain, famed for its white sand beaches, spectacular sunsets and vibrant marine life. We check into the eco friendly resort to explore Havelock island




ert

French entertainment company presents gravity-defying acrobatics performance in Puducherry




ert

Umberto Eco’s List of the 14 Common Features of Fascism

Creative Commons image by Rob Bogaerts, via the National Archives in Holland One of the key questions facing both journalists and loyal oppositions these days is how do we stay honest as euphemisms and trivializations take over the discourse? Can we use words like “fascism,” for example, with fidelity to the meaning of that word in world history? The […]




ert

Watch The Cure Perform a Three-Hour Concert in London, Celebrating the Release of Their New Album

Last Friday, The Cure celebrated the release of their new album, Songs of a Lost World, with a three-hour set at the Troxy in London. The band kicked off the show by performing all eight tracks from the album, before then playing another 23 songs, mostly hits from their large catalog of music. Originally live […]




ert

Bertrand Russell’s 10 Commandments for Living in a Healthy Democracy

Image by J. F. Horrabin, via Wikimedia Commons Bertrand Russell saw the history of civilization as being shaped by an unfortunate oscillation between two opposing evils: tyranny and anarchy, each of which contains the seed of the other. The best course for steering clear of either one, Russell maintained, is liberalism. “The doctrine of liberalism […]




ert

Enhanced magnetic properties and spin–phonon coupling in Ni-substituted α-Cu2V2O7: the role of bond length, bond angles, and distorted polyhedral structures

J. Mater. Chem. C, 2024, 12,17519-17532
DOI: 10.1039/D4TC02838D, Paper
A. Das, A. Banerjee, A. Tayal, S. Bandyopadhyay
Ni-Doped Cu2V2O7 exhibits enhanced magnetic hysteresis, zero-field exchange bias, and strong spin–phonon coupling, making it a promising candidate for spintronics applications.
The content of this RSS Feed (c) The Royal Society of Chemistry




ert

(C2H10N2)[Zn2(HPO4)2Cl2]: substitution-activated new short-wave ultraviolet phosphate with pivotal dual-property enhancement

J. Mater. Chem. C, 2024, 12,17482-17489
DOI: 10.1039/D4TC03504F, Paper
Zhi Fang, Yu-Ming Pan, Pei Han, Bing-Ping Yang, Mei-Hong Duan
A substitution-oriented rational approach to a short-wave ultraviolet phosphate, (C2H10N2)[Zn2(HPO4)2Cl2], results in significant dual-property enhancement.
The content of this RSS Feed (c) The Royal Society of Chemistry