Selecters in CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Selectors</title>
<style>
/* Element Selector */
div{
background-color: red;
}
/* Class Selector */
.red{
background-color: red;
}
/* Id Selector */
#green{
background-color: green;
}
/* Child Selectors */
div > p {
color: blue;
background-color: brown;
}
/* Descendant Selector */
div p {
color: blue;
background-color: brown;
}
/* Universal Selector */
* {
margin:0;
padding: 0;
}
/* Pseudo Selector */
a:visited{
color: yellow
}
a:link {
color: green;
}
a:active{
background-color: red;
}
a:hover{
background-color: yellow;
}
p:first-child{
background-color: aqua;
}
/* .box:first-child{
background-color: red;
} */
/* .box::first-line{
color: yellow;
} */
/* .boxes *{
color: blue;
border: 2px solid black;
}
p, a, .box, [data-color="primary"]{
padding-top: 45px;
} */
/* .box:nth-child(odd){
background-color: blue;
} */
/* .box:nth-last-child(2){
background-color: red;
} */
.boxes::before {
content: "Harry is good";
color: blue;
}
.boxes::after {
content: "Sigma course is also good";
color: red;
}
::selection {
background-color: black;
color: aqua;
}
.box::first-letter {
color: peru;
font-size: 45px;
}
input::placeholder {
color: rgb(84, 84, 88);
}
</style>
</head>
<body>
<main class="one">
<p>I am first</p>
<p>I am second</p>
</main>
<div class="red">
I am a div
<article>
<p>I am a para inside div</p>
</article>
</div>
<div id="green">
I am another div
</div>
<a href="https://www.google.com">Go to Google</a>
<a href="https://www.facebook2.com">Go to Facebook</a>
<div class="boxes">
<div data-color="primary" class="box">I am first box</div>
<div class="box">Hey I am a box</div>
<div class="box">Hey I am a box</div>
<input type="text" placeholder="Type your name here">
</div>
</body>
</html>
Comments
Post a Comment