Skip to main content

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 matches the first line in a block, and ::first-letter matches the first letter of the first line of a block.

The :nth-child() pseudo-class is a generalization of the :first-child selector, where you read n as the provided number. So :nth-child(1) means 1st child or first-child child,:nth-child(2) means 2nd child, and so forth.

So it is natural that :nth-child(1) selectselects the first child, and it would be highly confusing and illogical if it selected the second child!

CSS uses ordinal numbering because this is how humans naturally talk about such elements. You say the first paragraph of a text, not the zeroth paragraph or paragraph-zero.

The reason you even ask the question is probably because you are a programmer, and many programming languages indexesindex array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which doesdo not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example, all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL, Fortran, Lua, Julia and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing. For what itsit's worth, XPath and XQuery also use 1-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to choose 1-based indexing.

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 matches the first line in a block, and ::first-letter matches the first letter of the first line of a block.

The :nth-child() pseudo-class is a generalization of the :first-child selector, where you read n as the provided number. So :nth-child(1) means 1st child or first-child,:nth-child(2) means 2nd child and so forth.

So it is natural that :nth-child(1) select the first child, and it would be highly confusing and illogical if it selected the second child!

CSS uses ordinal numbering because this is how humans naturally talk about such elements. You say the first paragraph of a text, not the zeroth paragraph or paragraph-zero.

The reason you even ask the question is probably because you are a programmer, and many programming languages indexes array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which does not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL, Fortran, Lua, Julia and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing. For what its worth, XPath and XQuery also use 1-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to choose 1-based indexing.

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 matches the first line in a block, and ::first-letter matches the first letter of the first line of a block.

The :nth-child() pseudo-class is a generalization of the :first-child selector, where you read n as the provided number. So :nth-child(1) means 1st child or first child,:nth-child(2) means 2nd child, and so forth.

So it is natural that :nth-child(1) selects the first child, and it would be highly confusing and illogical if it selected the second child!

CSS uses ordinal numbering because this is how humans naturally talk about such elements. You say the first paragraph of a text, not the zeroth paragraph or paragraph-zero.

The reason you even ask the question is probably because you are a programmer, and many programming languages index array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which do not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example, all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL, Fortran, Lua, Julia and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing. For what it's worth, XPath and XQuery also use 1-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to choose 1-based indexing.

added 630 characters in body
Source Link
JacquesB
  • 62.4k
  • 21
  • 137
  • 190

If you count your own childrenCSS 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 matches the first line in a block, and ::first-letter matches the first letter of the first line of a block.

The :nth-child() pseudo-class is a generalization of the :first-child selector, where you would say "myread n as the provided number. So :nth-child(1) means 1st child or first child"-child, "my second child":nth-child(2) means 2nd child and so on, not "my zeroth child"forth. This

So it is simplynatural that :nth-child(1) select the first child, and it would be highly confusing and illogical if it selected the second child!

CSS uses ordinal numbering because this is how humans countnaturally talk about such elements. (Note: This isYou say the first paragraph of a text, not some subjective opinion by me. This is literally how ordinal numbers worksthe zeroth paragraph or paragraph-zero.)

The reason you even ask the question is probably because you are a programmer, and many programming languages indexes array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which does not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL, Fortran, Lua, Julia and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing. For what its worth, XPath and XQuery also use 1-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to chosechoose 1-based indexing.

If you count your own children you would say "my first child", "my second child" and so on, not "my zeroth child". This is simply how humans count. (Note: This is not some subjective opinion by me. This is literally how ordinal numbers works.)

The reason you even ask the question is probably because you are a programmer, and many programming languages indexes array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which does not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL, Fortran, Lua and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing. For what its worth, XPath and XQuery also use 1-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to chose 1-based indexing.

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 matches the first line in a block, and ::first-letter matches the first letter of the first line of a block.

The :nth-child() pseudo-class is a generalization of the :first-child selector, where you read n as the provided number. So :nth-child(1) means 1st child or first-child,:nth-child(2) means 2nd child and so forth.

So it is natural that :nth-child(1) select the first child, and it would be highly confusing and illogical if it selected the second child!

CSS uses ordinal numbering because this is how humans naturally talk about such elements. You say the first paragraph of a text, not the zeroth paragraph or paragraph-zero.

The reason you even ask the question is probably because you are a programmer, and many programming languages indexes array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which does not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL, Fortran, Lua, Julia and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing. For what its worth, XPath and XQuery also use 1-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to choose 1-based indexing.

added 66 characters in body
Source Link
JacquesB
  • 62.4k
  • 21
  • 137
  • 190

If you count your own children you would say "my first child", "my second child" and so on, not "my zeroth child". This is simply how humans count. (Note: This is not some subjective opinion by me. This is literally how ordinal numbers works.)

The reason you even ask the question is probably because you are a programmer, and many programming languages indexes array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which does not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL or, Fortran, Lua and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing. For what its worth, XPath and XQuery also use 1-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to chose 1-based indexing.

If you count your own children you would say "my first child", "my second child" and so on, not "my zeroth child". This is simply how humans count. (Note: This is not some subjective opinion by me. This is literally how ordinal numbers works.)

The reason you even ask the question is probably because you are a programmer, and many programming languages indexes array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which does not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL or Fortran and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to chose 1-based indexing.

If you count your own children you would say "my first child", "my second child" and so on, not "my zeroth child". This is simply how humans count. (Note: This is not some subjective opinion by me. This is literally how ordinal numbers works.)

The reason you even ask the question is probably because you are a programmer, and many programming languages indexes array and list items from 0. The reason for this is that in low level languages like C, an array is really a pointer to the memory address of the first item and the index is an offset relative to this pointer. So array[0] means address of first item, array[1] means address of the first item plus the size of 1 item, i.e. second item and so on.

Many higher-level languages which does not support pointer arithmetic directly have retained the 0-based indexing for consistency and familiarity. For example all languages with C-derived syntax - including JavaScript, even though arrays in JavaScript are implemented in a completely different way. But this is not at all universal - languages like COBOL, Fortran, Lua and some Basic's use 1-based indexing. (Visual Basic naturally chose the worst of both worlds by making it configurable.) So it is definitely not like every other language use 0-based indexing. For what its worth, XPath and XQuery also use 1-based indexing.

While most programmers will be familiar with both 1 and 0-based indexing, normal people will naturally count from 1, and CSS is a language designed not just for programmers but for designers and graphic professionals, so it is natural to chose 1-based indexing.

added 11 characters in body
Source Link
JacquesB
  • 62.4k
  • 21
  • 137
  • 190
Loading
added 341 characters in body
Source Link
JacquesB
  • 62.4k
  • 21
  • 137
  • 190
Loading
added 341 characters in body
Source Link
JacquesB
  • 62.4k
  • 21
  • 137
  • 190
Loading
added 341 characters in body
Source Link
JacquesB
  • 62.4k
  • 21
  • 137
  • 190
Loading
Source Link
JacquesB
  • 62.4k
  • 21
  • 137
  • 190
Loading