0

I want to indent the first

element after every heading element(h1, h2 e.t.c). How should I select this? I have found another way of doing this by giving a class to the elements and then targeting the class, however, I am still curious on how I should select the first element after another that is not it's child element. Thanks in advance.

Hou Zeng
  • 1
  • 3

1 Answers1

0

Adjacent Sibling Selector (+) The adjacent sibling selector is used to select an element that is directly after another specific element.

Sibling elements must have the same parent element, and "adjacent" means "immediately following".

The following example selects the first

element that are placed immediately after elements:

H1 + p {
  background-color: yellow;
}

Try it here.https://www.w3schools.com/css/css_combinators.asp

Prakash S
  • 1,695
  • 3
  • 11
  • 20