È stato utile?

Domanda

Advanced Selectors in CSS

CSSWeb DevelopmentFront End Technology

The Advanced Selectors in CSS includes Adjacent Sibling selector, attribute selector, direct child selector, nth-of-type selector, etc. It also includes General Sibling Selector, an example is shown below:

h1 ~ h3

Example of direct child selector −

div > span

Following is the code showing advanced selectors in CSS −

Example

 Live Demo

<html>
<head>
<style>
#red {
   color: red;
}
.green {
   background: green;
}
ul:nth-of-type(1) {
   background: rgb(0, 174, 255);
}
ul + h3 {
   border: 4px solid rgb(19, 0, 128);
}
a[href="https://www.wikipedia.org"] {
   font-size: 25px;
}
h1 ~ h3 {
   font-size: 40px;
}
div > span {
   background-color: DodgerBlue;
}
</style>
</head>
<body>
<h1>Advanced Selectors Example</h1>
<ul>
<li>Cow</li>
<li>Dog</li>
<li>Cat</li>
</ul>
<ul>
<li>Puma</li>
<li>Leopard</li>
<li>Cheetah</li>
</ul>
<h3>Animals</h3>
<div>
<span>Text sample</span>
<p>
Paragraph Text
<span>span text</span>
</p>
<p class="green">Paragraph Text</p>
<p id="red">Paragraph Text.</p>
<p class="green">Paragraph Text</p>
</div>
<a href="https://www.google.com">www.google.com</a>
<a href="https://www.wikipedia.org" target="_blank">www.wikipedia.org</a>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 11-May-2020 14:08:21
Advertisements
È stato utile?
Non affiliato a Tutorialspoint
scroll top