Sibling elements share the same parent.
To find a sibling element immediately before
or immediately after an element, we use the
nextElementSibling or previousElementSibling property.
Take a look at the example given below:
As can be seen, the next sibling element of h1 is the strong element and the previous sibling element of h1 is the a element.
Let's take a look at another example:
As can be seen, the next sibling element of ul is the p element and the previous sibling element of ul is the h1 element.