Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

#edpressoworkshop
css

What does the “+” plus sign CSS selector mean?

Oceanne Lai

Introduction

CSS has many selectors, and the + sign is one of them. A selector is a pattern of elements that directs the browser to which HTML elements should have the selected CSS property.

The + sign is best known as an adjacent sibling combinator, which means it separates two selectors, then combines the second selector with other elements which are placed immediately after the chosen selector. The + sign selector is used when the user wants to have the same styling for different elements.

Syntax

element1 + element2{
style code
}

The browsers that are supported by the + selector are listed below:

  • Apple Safari
  • Google Chrome
  • Internet Explorer 7.0
  • Opera
  • Firefox
  • Edge

Example

In this example code, we will apply different styles to the tags.

  • As you can see in the example above, h2+p and p don’t have the same style, as the first <p> is placed before the <h2>.
  • So, the style doesn’t apply to the first <p>.
  • The + sign essentially applies a style to all the tags that come after the first selector.

RELATED TAGS

#edpressoworkshop
css
RELATED COURSES

View all Courses

Keep Exploring