Skip to main content
48 votes

Why does :nth-child() in CSS start from 1 instead of 0?

CSS uses ordinal numbering when identifying elements in an ordered collection. For example, :first-child matches the first child element of a parent, @page :first matches the first page, ::first-line ...
JacquesB's user avatar
  • 59.8k
10 votes

Why does :nth-child() in CSS start from 1 instead of 0?

From the CSS Level 3 Selector Specification: 6.6.5.2. :nth-child() pseudo-class The :nth-child(an+b) pseudo-class notation represents an element that has an+b-1 siblings before it in the document ...
Adam Zuckerman's user avatar
10 votes
Accepted

Is loading the same .jpg in different qualities a waste of data?

No, neither the server, nor the client know that it is the same image. The images are unrelated to each other as far as anyone can tell. That's the factual reality. What you need is progressive ...
Mike Nakis's user avatar
  • 32.2k
3 votes

Why does :nth-child() in CSS start from 1 instead of 0?

Probably for consistency with XPath, another XML / HTML processing language. Which begs the question, why does XPath use 1 based indexing? See https://stackoverflow.com/questions/3319341/why-do-...
user949300's user avatar
  • 8,859
1 vote
Accepted

Using JS and CSS parent selector to replace media queries: is it a good practice?

I do think you have something very valuable in your hands. The idea to have CSS to handle state having as base HTML properties is very useful, and if combined with accessibility, it can help you both ...
Bernardo Benini Fantin's user avatar
1 vote

How do big publishers edit their websites?

You need to better understand what happens when source code changes. Let's imagine that the website has a hardcoded logotype. Recently, the marketing decided to change the logotype, and the new one ...
Arseni Mourzenko's user avatar
1 vote

Allowing a user on one page to be able to cause an event on another

You need to use simple ajax function that would keep pooling from a server for new alerts. websocket is good alternative here, but you can do that with normal ajax http calls. When the form is ...
Shaunak Sontakke's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible