Css
Css
CSS
Selectors
A Beginner's Guide
Selector p {
color: red ;
}
Page 1
CSS tips
Example:
<html >
<head>
<title>Basic HTML Document</title>
</head>
<body>
<h1> Welcome to My Website</h1>
<p> This is a basic HTML document.</p>
</body>
</html>
Page 2
CSS tips
Example:
<html >
<head>
<title>Basic HTML Document</title>
</head>
<body>
<p> Welcome to My Website</p>
<p> This is a basic HTML document.</p>
</body>
</html>
Page 3
CSS tips
3. Class Selector ( . )
Description: Selects elements with a specific class.
Example:
<html >
<head>
<title>Basic HTML Document</title>
</head>
<body>
<p class=”text”> Welcome</p>
<span class=”text”> HTML document.</span>
</body>
</html>
Page 4
CSS tips
4. ID Selector ( # )
Description: Select an element with a specific ID..
Example:
<html >
<head>
<title>Basic HTML Document</title>
</head>
<body>
<p id=”text”> Paragraph 1</p>
<p >Paragraph 2</p>
</body>
</html>
Page 5
CSS tips
Example:
<body>
<div>
<p> Paragraph 1</p>
<p>Paragraph 2</p>
</div>
<p>Paragraph 3</p>
</body>
Page 6
CSS tips
<body>
<div>
<p> Paragraph 1</p>
<p>Paragraph 2</p>
<article>
<p>Paragraph 3</p>
</article>
</div>
</body>
Page 7
CSS tips
<body>
<div>
<h1> Paragraph 1</h1>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
</div>
</body>
Page 8
CSS tips
<body>
<div>
<h1> Paragraph 1</h1>
<p> Paragraph 2</p>
<p> Paragraph 3</p>
</div>
</body>
Page 9
CSS tips
9. Attribute Selector
Description: Selects elements based on the presence
or value of an attribute.
Example:
<body>
<div>
<h1> Paragraph 1</h1>
<p> Paragraph 2</p>
<input type=”text” />
</div>
</body>
Page 10
CSS tips
<body>
<div>
<h1> Paragraph 1</h1>
<p> Paragraph 2</p>
<input type=”text” />
</div>
</body>
Page 11
CSS tips
11. Pseudo-classes ( : )
Description: Selects elements in a specific state.
Hint: The selected element will change its text color to red when
the cursor hovers over it.
<body>
<div>
<h1> Paragraph 1</h1>
<p> Paragraph 2</p>
<input type=”text” />
</div>
</body>
Page 12
CSS tips
12. Pseudo-elements ( :: )
Description: Selects part of an element.
<body>
<div>
<h1> Paragraph 1</h1>
<p> Paragraph 2</p>
<input type=”text” />
</div>
</body>
Page 13
CSS tips
Page 14