Search
 
SCRIPT & CODE EXAMPLE
 

CSS

css combinators

/*Looking inside - Selects all the li elements placed (anywhere) inside the ul;Descendant selector */
ul li

/*Looking inside - Selects only the direct li elements of ul; i.e. it will only select direct children li of ul; Child Selector or Child combinator selector*/
ul > li

/* Looking outside - Selects the ul immediately following the ul; It is not looking inside, but looking outside for the immediately following element; Adjacent Sibling Selector */
ul + ul

/* Looking outside - Selects all the ul which follows the ul doesn't matter where it is, but both ul should be having the same parent; General Sibling Selector */
ul ~ ul
Comment

CSS Combinators

There are four different combinators in CSS:

    descendant selector (space)
    child selector (>)
    adjacent sibling selector (+)
    general sibling selector (~)
Comment

css combinators

/* Scroll for HTML part for visualization 
There are four different combinators in CSS:
 Descendant Selector - selects all of specified parent  */
ul li{
    background-color: orange; 
}

/* Child Selector - selects only children */
ul > li{
    background-color: red;
}

/* Adjacent Sibling Selector - selects only the immediate sibling*/
ul + li{
    color: blue;
}

/* General Sibling Selector - selects all the siblingss */
ul ~ li{
    background: yellow;
}

/* Next is the HTML part for the CSS
<body>
    <h2>Combinators CSS</h2>
    <ul>
      <li>Child1</li>

      <ol>
        <li>Descendant1</li>
        <li>Descendant2</li>
      </ol>
      <li>Child2</li>
      <li>Child3</li>
      <li>Child4</li>
    </ul>
    <li>Sibling1</li>
    <li>Sibling2</li>
  </body>
*/
Comment

selectors combinators css

/* selects any <span> that is inside a <p>, which is inside an <article>  */
article p span { ... }

/* selects any <p> that comes directly after a <ul>, which comes directly after an <h1>  */
h1 + ul + p { ... }
Comment

CSS Combinators

div p {
  background-color: yellow;
}
Comment

PREVIOUS NEXT
Code Example
Css :: background 
Css :: css position 
Css :: symfony app css not working 
Css :: text in one line css 
Css :: chrome close tab after print 
Css :: WordPress Permalink for bread crumbs 
Css :: enque script only on specific archive page 
Css :: why wont text color of a div change 
Css :: progress bar with width gradient 
Css :: top 10 customers odoo 
Css :: combine text styles 
Css :: footer for front end developer 
Css :: ecto generator create new mvc 
Css :: change height primeng progress spinner 
Css :: flex index css 
Css :: total income of labrada company in india 
Css :: css change scroll anchor point under navbar 
Css :: css chess pieces 
Css :: changing the dots of the ul to ticks 
Css :: css tips and tricks to handle the complicated stuffs in design part which is helpfull to handle at tha critical time and to deliver requirement to the client to the main resource 
Css :: Getting strated with boostrap css for html and Reacr framework 
Css :: jitsi meet index.html add css version 
Css :: how to style boxicon icons in css 
Css :: css for floting input label 
Css :: tailwind css checked 
Css :: css file verlinken 
Css :: margin collapse 
Css :: alternative for lodash omit in javascript 
Css :: trigger before update 
Css :: white block on the left css 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =