Search
 
SCRIPT & CODE EXAMPLE
 

CSS

selectors in css

/*Advanced selectors*/
    h2 + p  /*every paragraph that is after "h2" */
    textarea ~ button /*every button that is aftrer textarea with same parent (<form> is the same parent in this example)*/
    ul > li /*every signle "li" inside of the "ul"*/
    ul li /*every "li" that goes up to "ul"*/

/*Attribute selectors*/
    p[class="review"] /*all of paragraphs with review class on them*/
    img[href^="../my code guide/"] /*every image that starts with that addres (replacing "=" with"^=")*/
    img[href$="../my code guide/"] /* its end with this attribute*/
    img[href*="../my code guide/"] /*if its contain anywhere*/
    h1[class~="site-header"] /*only works with white space seperator*/
    h1[class|="subtitle"] /*selects ones that starts with "subtitle" or "subtitle" and "-" in following*/
Comment

selectors in css

/*Advanced selectors*/
    h2 + p  /*every paragraph that is after "h2" */
    textarea ~ button /*every button that is aftrer textarea with same parent (<form> is the same parent in this example)*/
    ul > li /*every signle "li" inside of the "ul"*/
    ul li /*every "li" that goes up to "ul"*/

/*Attribute selectors*/
    p[class="review"] /*all of paragraphs with review class on them*/
    img[href^="../my code guide/"] /*every image that starts with that addres (replacing "=" with"^=")*/
    img[href$="../my code guide/"] /* its end with this attribute*/
    img[href*="../my code guide/"] /*if its contain anywhere*/
    h1[class~="site-header"] /*only works with white space seperator*/
    h1[class|="subtitle"] /*selects ones that start with "subtitle" or "subtitle" and "-" in following*/
Comment

selector css

*all elements
divall div tags
div,pall divs and paragraphs
div pparagraphs inside divs
div > pall p tags, one level deep in div
div + pp tags immediately after div
div ~ pp tags preceded by div
.classnameall elements with class
#idnameelement with ID
div.classnamedivs with certain classname
div#idnamediv with certain ID
#idname *all elements inside #idname
Comment

CSS Selector


.class1.class2 	    .name1.name2 	Selects all elements with both name1 and name2 set within its class attribute
.class1 .class2 	.name1 .name2 	Selects all elements with name2 that is a descendant of an element with name1

*                	* 	        Selects all elements
element 	        p 	        Selects all <p> elements
element.class       p.intro 	Selects all <p> elements with class="intro"
element,element 	div, p 	    Selects all <div> elements and all <p> elements
element element 	div p 	    Selects all <p> elements inside <div> elements
element>element 	div > p 	Selects all <p> elements where the parent is a <div> element
element+element 	div + p 	Selects the first <p> element that is placed immediately after <div> elements
element1~element2 	p ~ ul    	Selects every <ul> element that is preceded by a <p> element


/*Attribute selectors*/
    p[class="review"] /*all of paragraphs with review class on them*/
    img[href^="../my code guide/"] /*every image that starts with that addres (replacing "=" with"^=")*/
    img[href$="../my code guide/"] /* its end with this attribute*/
    img[href*="../my code guide/"] /*if its contain anywhere*/
    h1[class~="site-header"] /*only works with white space seperator*/
    h1[class|="subtitle"] /*selects ones that start with "subtitle" or "subtitle" and "-" in following*/
Comment

what is css selector

div { color: red; } // the "div" in .css is a selector targeting all <div> elements
simpleSelector = document.querySelectorAll()("div"); // all divs 
complexSelector = document.querySelector("div.user-panel.main input[name='login']")  // the first <input> element with the name "login" (<input name="login"/>) located inside a <div> whose class is "user-panel main" (<div class="user-panel main">) in the document is returned
Comment

PREVIOUS NEXT
Code Example
Css :: display block 
Css :: move cursor 
Css :: pading 
Css :: animation 
Css :: animation in css 
Css :: What is the "style", when creating an internal CSS? 
Css :: rel="noopener noreferrer 
Css :: target element pseudo-classes 
Css :: flex item: 1; 
Css :: jquery or selector 
Css :: label for centered image 
Css :: button slanted slide on hover 
Css :: css all children of type 
Css :: css tutorial point 
Css :: no nobr substitute in html 
Css :: set default rem css 
Css :: pacSelectFirst( submit button 
Css :: css para paginado de ul 
Css :: Which of the following CSS property is used to specify the space between every letter inside an element? 
Css :: felx-wrap css 
Css :: cons;0 ccs 
Css :: javascript select element that does not have attribute 
Css :: const Schema 
Css :: image with colored background html css tigether 
Css :: writting css with twin.macro and styled components 
Css :: unable to select text in website css cursor type 
Css :: padding order nth-child 
Css :: overwrite safari dropdown css 
Css :: cop pics css 
Css :: css not hover div right hide 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =