Snippets Collections
:root {
  --color-main: #333333; 
  --color-alert: #ffecef;
}

.error { 
	color: var(--color-alert); 
}
/* Use #CSS attribute selectors to display links when <a> has no text value but the `href` has a link. */

a[href^="http"]_empty::before {
    content: attr(href);
}
::first-line	
/*Selects the first line of content in an element. Typically applied to paragraphs (for example p::first-line). Useful for first-line run-in effects.*/

::first-letter	
/*Selects the first letter of an element. Typically applied to paragraphs or headings (for example, p::first-letter). Useful for creating initial and drop caps.*/

::before	
/*Inserts content before a selection. Has all sorts of uses: generating opening quote marks for pull quotes, creating separators for navigation bar links, and much more.*/

::after	
/*Just like ::before, with all the same uses, but generates content after a selection.*/

::selection	
/*Changes the appearance of selected text.*/
a:has( > img ) { 
	border: 1px solid #000; 
}
header img:only-child { 
	width: 100%; height: auto; 
}
.nav li:not(:last-child) {
  border-right: 1px solid #666;
}
.nav li:not(:last-child) {
  border-right: 1px solid #666;
}
/* list with not selector */

.post > *:not( img ):not( video ) {
    margin-left: auto;
    margin-right: auto;
    max-width: 50rem;
    padding-left: 5%;
    padding-right: 5%;
}
div[class*="left"] {
	float: left;
}
/* all ULs after p */
p ~ ul {
background-color: #f00;
}
/* General sibling selector */
h4 ~ p {
    font-weight:bold;
}
/*
General Sibling Combinator
*/

figure ~ p {}
article:first-of-type,
article:last-of-type {
	margin: 10px 0;
}
/* Element not only child */

div p:last-child:not(:only-child) { 
	font-weight: bolder; 
}
/* Select all <a> that are hrefs: */
a[href]{}

/* Select all elements that have a class (useful if JS is adding classes somewhere) */
article[class]{}

/* Select an ID, but with the specificity of a class:  */
section[id="sideBar"]{color: red}

/* Style all links that are fully qualified URLs, knowing that ^ means "starts with": */
a[href^="http"]{}

/* Need to style a link to a ZIP or a PDF? Totally fine, too. Use the $ which means "ends with" */
a[href$=".zip"]:after{content:"(zip)"}

/* Style an image based on one word existing in the alt attribute? Let's use the space substring selector: */
img[alt~="Insurance"]{}

/* Style an image based on the name of the image file itself? Also doable, even if you're image is this-image-shot-april-2-2014.png. The | is a hyphen substring selector: */
img[src|="-april-"]{}
div[class*="test"] {
    background: #000;
}
$("*")	                Selects all elements
$(this)	                Selects the current HTML element
$("p.intro")	        Selects all <p> elements with class="intro"
$("p:first")	        Selects the first <p> element	Try it
$("ul li:first")	Selects the first <li> element of the first <ul>
$("ul li:first-child")	Selects the first <li> element of every <ul>
$("[href]")	        Selects all elements with an href attribute
$("a[target='_blank']")	Selects all <a> elements with a target attribute value equal to "_blank"	Try it
$("a[target!='_blank']")	Selects all <a> elements with a target attribute value NOT equal to "_blank"	Try it
$(":button")	Selects all <button> elements and <input> elements of type="button"	Try it
$("tr:even")	Selects all even <tr> elements	Try it
$("tr:odd")	Selects all odd <tr> elements
$(document).ready(function(){
  $("button").click(function(){
    $("p").hide();
  });
});
star

Mon Apr 07 2025 14:27:08 GMT+0000 (Coordinated Universal Time)

#css #selector #custom-properties #variables
star

Mon Apr 07 2025 14:25:03 GMT+0000 (Coordinated Universal Time)

#css #selector #attribute #link
star

Mon Apr 07 2025 14:24:01 GMT+0000 (Coordinated Universal Time)

#css #selector #pseudo
star

Mon Apr 07 2025 14:23:05 GMT+0000 (Coordinated Universal Time)

#css #selector #has
star

Mon Apr 07 2025 14:22:25 GMT+0000 (Coordinated Universal Time)

#css #selector #only
star

Mon Apr 07 2025 14:21:53 GMT+0000 (Coordinated Universal Time)

#css #selector #not
star

Mon Apr 07 2025 14:20:11 GMT+0000 (Coordinated Universal Time)

#css #selector #not
star

Mon Apr 07 2025 14:18:54 GMT+0000 (Coordinated Universal Time)

#css #selector #not
star

Mon Apr 07 2025 14:18:03 GMT+0000 (Coordinated Universal Time)

#css #selector #list
star

Mon Apr 07 2025 14:16:20 GMT+0000 (Coordinated Universal Time)

#css #selector #empty
star

Mon Apr 07 2025 14:15:21 GMT+0000 (Coordinated Universal Time)

#css #selector #attribute
star

Mon Apr 07 2025 14:13:36 GMT+0000 (Coordinated Universal Time)

#css #selector
star

Mon Apr 07 2025 14:12:47 GMT+0000 (Coordinated Universal Time)

#css #selector
star

Mon Apr 07 2025 14:12:08 GMT+0000 (Coordinated Universal Time)

#css #selector
star

Mon Apr 07 2025 14:11:04 GMT+0000 (Coordinated Universal Time)

#css #selector
star

Mon Apr 07 2025 14:10:32 GMT+0000 (Coordinated Universal Time)

#css #selector
star

Mon Apr 07 2025 14:09:42 GMT+0000 (Coordinated Universal Time)

#css #selector #attribute
star

Mon Apr 07 2025 14:08:27 GMT+0000 (Coordinated Universal Time)

#css #selector
star

Mon Dec 18 2023 03:29:44 GMT+0000 (Coordinated Universal Time) https://www.w3schools.com/jquery/jquery_selectors.asp

#selector #jqueryselector #selectelements
star

Mon Dec 18 2023 03:17:23 GMT+0000 (Coordinated Universal Time) https://www.w3schools.com/jquery/jquery_selectors.asp

#jquery #selector #jqueryselector #documentready function #documentready #document.ready #jqueryonclick

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension