Hello friends in this blog post we will learn about web page development Describe about (CSS Selector) (CLASS:9) computer engineering students Now lets start.
CSS SELECTOR
→ A css selector is a pattern to match the elements based on their element name,id,class,attribute and more in an Html document.
→ The associated style rules is applied to the elements that match the selector pattern.
* The Element Selector *
→ The element selector elements based on the element name.
→ Example:
p{
text-align:center;
color:red;
}
* The Id Selector *
→ The id selector is used to define style rules for a signal or unique element.
→ The id selector is defined with a hash sign (#) immediately followed by the id value.
→ Example:
<!doctype html>
<html>
<style>
#para1{
text-align:center;
color:red;
}
</style>
</head>
<body>
<p id="para1">hello, class9</p>
<p>This paragraph is not affected by the style</p>
</body>
</html>
* The Class Selector *
→ The class selector is used to selects element with a specific class attribute.
→ To select elements with a specific class,write a period ( . ) character,followed by the name of the class.
→ Example:
<!doctype html>
<html>
<style>
.center{
text-align:center;
color:red;
}
</style>
</head>
<body>
<h1 class="center">Computer Engineering</h1>
<p class="center">Computer Engineering</p>
</body>
</html>
0 Comments