option

Shift in snacking patterns: Indian consumers opt for healthier and plant-based options

According to the Mondelez International snacking report, Indian consumers are showing an increasing interest in plant-based snacks




option

F&O Query: Should you hold call options on Reliance Industries and ICICI Bank?




option

F&O Query: Should you hold call options on Infosys and Voltas?




option

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

option

Venkatesh Maha: After three years, crowdfunding seemed the best option for ‘Marmaanuvu’

Director Venkatesh Maha talks about taking the crowdfunding route for his new Telugu film ‘Marmaanuvu’ asserting he will not let down the film-loving audience




option

Why a cruise would be the best option for a memorable vacation?

Post the pandemic, it is smooth sailing for cruising as an increasing number of Indians pack their bags to enjoy vacations on luxury liners




option

Improved photovoltaic performance and stability of perovskite solar cells by adoption of an n-type zwitterionic cathode interlayer

Mater. Horiz., 2024, Advance Article
DOI: 10.1039/D4MH00253A, Communication
Young Wook Noh, Jung Min Ha, Jung Geon Son, Jongmin Han, Heunjeong Lee, Dae Woo Kim, Min Hun Jee, Woo Gyeong Shin, Shinuk Cho, Jin Young Kim, Myoung Hoon Song, Han Young Woo
Integration of NDI-ZI as a cathode interlayer in perovskite solar cells improves both device efficiency and stability, mitigating halide and Ag ion migration by chemically capturing ions via electrostatic Coulombic interactions.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




option

The Wheels of Change: Technology Adoption, Millwrights, and Persistence in Britain's Industrialization [electronic journal].




option

What Option Prices tell us about the ECB's Unconventional Monetary Policies [electronic journal].




option

The Value of Information in Technology Adoption: Theory and Evidence from Bangladesh [electronic journal].




option

Technology Adoption and Productivity Growth: Evidence from Industrialization in France [electronic journal].

National Bureau of Economic Research




option

Technology Adoption and Access to Credit via Mobile Phones [electronic journal].




option

Skin-in-the-Game in ABS Transactions: A Critical Review of Policy Options [electronic journal].




option

Peer Effects in Product Adoption [electronic journal].

National Bureau of Economic Research




option

Options and the Gamma Knife [electronic journal].




option

The option value of vacant land and the optimal timing of city extensions [electronic journal].




option

Option Prices and Costly Short-Selling [electronic journal].




option

More Power to the People: Electricity Adoption, Technological Change and Social Conflict [electronic journal].




option

Managing Channel Profits when Retailers have Profitable Outside Options [electronic journal].




option

Machine imports, technology adoption and local spillovers [electronic journal].




option

The Limits of Lending? Banks and Technology Adoption across Russia [electronic journal].




option

Immigration, Internal Migration, and Technology Adoption [electronic journal].




option

Endogenous Information Sharing and the Gains from Using Network Information to Maximize Technology Adoption [electronic journal].




option

Commodity Option Pricing Efficiency before Black Scholes Merton [electronic journal].




option

Childbearing Postponement, its Option Value, and the Biological Clock [electronic journal].




option

MCX to launch monthly gold option contract

MCX reduces gold option expiry to monthly, improving liquidity and attracting more participants, benefiting jewellers and increasing revenue




option

India is leading in AI adoption at 30%, surpassing global average of 26%: BCG report




option

Why this fund is a good option for investors wanting to play the consumption theme

Performance, portfolio composition and downside protection are three reasons that work for Mirae Asset Great Consumer Fund




option

Options for hot water

Energy consumed in heating water may not appear like a major problem, compared to industries, but thousands of homes each with 2 or 3 heaters may surpass many industries in energy consumption.




option

Why power from Sri Lanka is a better option than offshore wind

Wind industry sources estimate island nation has 65 GW onshore potential




option

Editorial. Right option

Curbs on equity derivatives welcome




option

Career options in stem cell research

The field of stem cell research offers lucrative career options for people looking for something different in the field of medical science.




option

A review of carbon recovery in sewage treatment and analysis of product options for a typical water recycling plant

Environ. Sci.: Water Res. Technol., 2024, Advance Article
DOI: 10.1039/D4EW00160E, Critical Review
Arash Mohseni, Linhua Fan, Li Gao, Joel Segal, Felicity Roddick
Reviewed existing and emerging technologies for carbon recovery from WWTPs, best options investigated as case study for typical conventional plant.
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




option

Are these ‘Options’ for us?

Market participants generally welcome ‘options’ trading on commodity derivatives but want to know the nitty-gritty




option

How to go about trading in options?

First understand the Greek and Latin of these derivative products and implement smart strategies to be in-the-money, say seasoned players




option

Provide more time to submit options for higher PF pension: CITU




option

When spilling the beans is not an option

If Where Eagles Dare belongs in the pantheon of great getaway films, that is partly because of the impressive number of modes of transport deployed, says Geoff Dyer




option

Outlook 2025: Expect more tech adoption, strategic partnerships, says Nasscom Chairperson

Weighing-in on global debate on whether AI will lead to major layoffs, she said Artificial Intelligence needs to be seen as an enabler that can help amplify skills and boost productivity




option

Amazon’s refreshed Kindle lineup comes with faster, 7-inch option, and a first-ever colour Kindle

Amazon has launched an entirely new lineup of Kindle devices, introducing its first-ever colour Kindle, a reimagined Kindle Scribe, and more.




option

A U.K. option for a controlled substance

TPI Enterprises, an Australian poppy processor, enters the restrictive British codeine market via a contract with Sterling Pharma Solutions




option

Everstone Capital evaluates exit options for Translumina, Everlife; IPO most likely

The IPO is likely to be in the range of $300-350 million, sources say




option

A smart option

With multiple players in self drive car market, city dwellers can now share their cars on the e-platforms




option

Onam: Handmade pappadams have many takers in spite of machine-made options flooding the market in Thiruvananthapuram

Pappadams are a must for the grand Onam feast and units selling handmade pappadams in Thiruvananthapuram have a steady clientele



  • Life & Style

option

Keeping a Two-Page Resume is Always the Best Option to Impress Employers

A recent survey conducted by TimesJobs suggests that recruiters are never interested in a CV longer than two pages. The survey also reveals that about 43 pct pinpoints the importance of a CV’s length.




option

Embraer left with limited options after collapse of Boeing deal

Joint venture had been pegged as a game-changer for Brazilian aircraft manufacturer




option

What are Declan Rice's options should the midfielder leave West Ham this summer?

A big-money transfer, in the region of £70m, to a top European club has been mooted for some time for Rice, but just what are his options should West Ham be open to selling their star man?




option

Best FD Option : यहां मिल रहा अब भी 9 फीसदी तक ब्याज

नयी दिल्ली। कोरोनावायरस ने बैंकों और फाइनेंसिंग कंपनियों की स्थिति बिगाड़ कर रख दी। बैंकों और बाकी फाइनेंसिंग कंपनियों की ऐसी हालत खराब हुई कि उन्होंने अपनी निवेश स्कीम पर रिटर्न यानी ब्याज की दर कम कर दी। अगर आप एफडी




option

'Come up with another option': Pat Cummins on banning saliva and sweat to shine one side of the ball

Australia fast bowler Pat Cummins need an alternative option if using spit and sweat, which is used to help shine the ball is banned in the wake of the COVID-19 pandemic.




option

Holding French Open without fans and later on are options




option

Yao Ming offers options for restart of Chinese basketball

Yao Ming offers options for restart of Chinese basketball