Web development becomes easier when we understand how HTML and CSS work together. Recently, I learned about selectors, the nth-child pseudo-class, CSS overflow, and the Playwright automation tool. These concepts are very useful for designing websites and testing web applications.
Selectors in HTML & CSS
Selectors are used in CSS to target HTML elements and apply styles to them. They help developers style specific elements without affecting the entire webpage.
Types of CSS Selectors
- Element Selector Targets HTML tags directly.
p {
color: blue;
}
P is a element selector. It applies style only to all p tags.
2. Class Selector
Uses . before the class name.
.text {
font-size: 20px;
}
<p class="text">Hello</p>
3. ID Selector
Uses # before the ID name.
#title {
color: red;
}
<h1 id="title">Welcome</h1>
4. Universal Selector
Targets all elements.
* {
margin: 0;
}
nth child in css
nth child is a pseudo-class selector used to select elements based on their position.
li:nth-child(2) {
color: blue;
}
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
Here, the second list item becomes blue.
Uses of nth-child:
- Helps style alternate rows.
- Useful in tables and lists.
- Reduces extra class usage. Overflow Overflow controls what happens when content exceeds the size of its container.
Types of Overflow
Overflow Hidden
Hides extra content.
overflow: hidden;
Overflow Scroll
Adds scrollbars.
overflow: scroll;
Overflow Auto
Adds scrollbar only when needed.
overflow: auto;
Playwright Tool
Playwright is a modern automation testing tool used for testing web applications.It supports multiple browsers like:
- Chrome
- Firefox
- Edge
- Safari
Uses of Playwright
- Browser automation.
- UI testing.
- End-to-end testing.
- Website functionality testing.
Top comments (0)