CSS :nth-child(n) selector26 Mar 2025 | 2 min read This selector is used for matching the elements based on their position regardless of the type of its parent. The n can either be a keyword, formula, or a number. It is used to match the elements based on their position within a group of siblings. It matches each element, which is the nth-child. SyntaxFollowing are the syntax of this selector: The "n" in the parentheses is the argument that represents the pattern for matching elements. It can be a functional notation, even or odd. Odd values represent the elements whose position is odd in series like 1, 3, 5, etc. Similarly, the even values represent the elements whose position is even in series like 2, 4, 6, etc. Functional notation (An+B): Functional notation represents those elements whose siblings position match the An+B pattern, where A is the integer step size, n is any positive integer starting from 0, and B is the integer offset. Let' see some illustrations. Example1In this example, we are using the functional notation 3n+4 that will represent the elements: (3×0)+4 = 4, (3×1)+4 =7, and many more. Example2In this example, we are going to use odd and even keywords that match those elements whose index is odd or even. It is to be noted that the first child index is 1. Next TopicCSS sticky |
property This CSS property specifies whether or not an element shows some action when the pointer event is triggered upon it. The pointer-events are triggered by touch, stylus, mouse click, and many more. The pointer-events property controls how the HTML elements respond to events such as...
2 min read
This CSS property specifies the right offset for the horizontal positioned elements and does not affect the non-positioned elements. It is one of the four offset properties that are left, top, and bottom. When both left and right properties are defined, the right value has a preference if...
3 min read
What is CSS Inline? A value for the display property in CSS called inline specifies how an element will be rendered within the flow of other content on a web page. An element is an inline-level element if it has the display value of inline. What is ? Cascading...
6 min read
In today's world, you hardly have any opportunity to be heard or noticed a second time in the virtual world, where the canvas of creativity is never complete. As a web designer/developer, you sell out designing artistically attractive and fun sites. Using CSS animation keyframes can...
9 min read
The CSS float property is a positioning property. It is used to push an element to the left or right, allowing other element to wrap around it. It is generally used with images and layouts. To understand its purpose and origin, let's take a look to...
2 min read
CSS Cursor Pointer What is Cursors in CSS? Every day, we already use customized cursors. This interaction is made possible by using modified cursors, such as when you hover over buttons, the pointer cursor transforms into a hand, or when you hover over the text and the...
5 min read
At the bottom of every page, the footer is one of a website's most underrated areas. Despite this, it may be utilised to persuade readers to continue on your website if they can't find the information they're searching for in the main content area. Introduction to When...
3 min read
The radio button is an HTML element that helps to take input from the user. Although it is hard to style the radio button, pseudo-elements makes it easier to style the radio button. Radio buttons are applied when there is the requirement of a single...
3 min read
CSS As the name implies, this CSS property is used to specify the page break inside the element, when printing the document. This CSS property cannot be used on absolutely positioned elements or an empty <div> element that does not generate a box. It inserts...
3 min read
The bottom property in CSS is used to specify the bottom position for the vertical positioned elements. It does not affect the non-positioned elements. It is one of the four offset properties that are left, right, and top. The effect of this property depends on the...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India