css select id code example

Example 1: css id selector

#id{
    color:red;
}

Example 2: how to call an id in css

<style>
  #selector {
  color: red;
}
/* # is id selector */
</style>


<div id="selector">
<p>This is an id</p>
</div>

Example 3: css selectors

* {
color: pink;
}
h1, h2 {Select all h1 and h2}
li a {select all anchor inside a list}
h1 + p {select all p placed after an h1}
div > li {all li directly in a div}

Example 4: css how to style id

/*put a # infront of the id*/
/*<section id="example"></section>*/
#example{
	margin: auto;
}

Example 5: CSS how to select ID

#id-selector-name{
  font-size: 20px;
}

.class-selector-name{
  color: green;
}

Example 6: what is a css selector

h1 {
  color: red;
}

In this CSS code example that sets the color of all h1s to red 
the "h1" is the selctor because we are applying this style to 
the h1s.

Tags:

Misc Example