w10schools
Login Register
  • Home
  • Tutorials
    • HTML, CSS
      • HTML, HTML5
      • CSS, CSS3
    • XML
    • JavaScript, AJAX
    • PHP
    • Ruby on Rails
      • Ruby
      • Rails
    • ASP.NET
      • ASP
      • C# .NET
    • Java
      • JSP
    • Databases
      • MySQL
      • MSSQL Server
      • Oracle
    • Web Server
      • Windows
      • Linux
      • Apache
      • IIS
    • Design
      • Dreamweaver
      • Flash
      • Photoshop
      • Fireworks
      • CorelDRAW
      • Illustrator
  • References
    • HTML
      • Bootstrap
    • CSS
      • CSS Selectors
      • Sass
    • JavaScript
    • Mobile Apps
      • Cordova
    • Ruby on Rails
      • Ruby
      • Rails
    • PHP
      • Function
      • Language
      • CodeIgniter
      • Phalcon
      • PHPUnit
      • Symfony
      • Drupal
      • Yii
      • Laravel
    • Perl
      • Perl
    • Python
      • Python
      • Django
      • NumPy
      • Pandas
      • scikit-image
      • scikit-learn
      • Statsmodels
      • Matplotlib
    • Lua
      • Lua
    • C, C++
      • C
      • C++
    • Server
      • Docker
      • Apache HTTP Server
      • Nginx
    • Database
      • PostgreSQL
    • Big Data
      • TensorFlow
    • Game Development
      • Phaser
      • LÖVE
  • Articles
    • News
    • General
      • Website Promotion
      • Online Advertising
      • Make Money Online
    • Editorials
    • Interviews
    • Web Roundups
  • Resources
    • Design
      • Fonts
      • Graphics
      • Vectors
      • Templates
      • UI (User Interface)
      • Brushes
      • Patterns, Backgrounds
      • Textures
    • Web Development
      • HTML, CSS
      • XML
      • JavaScript, AJAX
      • Ruby on Rails
      • PHP
      • Java
      • .NET
      • Python
      • Perl
      • Flash
    • Mobile Application Development
      • Mobile Development Tools
      • Swift
    • Online Services
      • Online Storage
      • Web Hosting
  • Tools
    • Generators
  • References
  • CSS
  • CSS Selectors

General Sibling Selector: element1 ~ element2

Pattern:

element1 ~ element2

 

Definition:

The element1 ~ element2 selector matches every element2 that is a sibling of element1 (they need to have the same parent), and element1 must precede (not necessarily immediately) element2. 

 

 

Examples:

Style every <p> element that is placed after an <h1> element with the same parent

h1 ~ p { margin-top: 10px; }
w10schools
w10schools
2014-11-10 04:41:25
~
Comments
Leave a Comment

Please login to continue.

Popular Articles
Adjacent Sibling Selector: element1 + element2 Pattern: element1 + element2   Definition: The element1 + element2 selector matches every element2 where element1 and element2 are sibling element
Child Selector: element1 &gt; element2 Pattern: element1 > element2   Definition: The element1 > element2 selector matches every element2 that is the child of element1. A child se
Descendant Selector: element1 element2 Pattern: element1 element2   Definition: The element1 element2 selector matches every element2 that is the descendant of element1. A descendant se
Next siblings selector (“prev ~ siblings”) Selects all sibling elements that follow after the "prev" element, have the same parent, and match the filtering "siblings" selector.
.siblings() Get the siblings of each element in the set of matched elements, optionally filtered by a selector. Given


Return to View
  • Facebook
  • Tweet
  • Digg it
  • Stumbleupon
  • Delicious
  • Plus Share

Designed by : w10schools

service@w10schools.com

Our Partners: aeeble – Providing content publishing and search solutions