from bs4 import BeautifulSoup
# Sample HTML for practicing CSS selectors
= """
practice_html <html>
<body>
<div id="header" class="top-section">
<h1 class="main-title">Welcome to Our Store</h1>
<nav class="navigation">
<a href="/home">Home</a>
<a href="/products">Products</a>
<a href="/contact">Contact</a>
</nav>
</div>
<div id="main-content">
<div class="product featured" data-price="199.99">
<h2 class="product-title">iPhone 15</h2>
<p class="description">Latest smartphone with amazing features</p>
<span class="price">$199.99</span>
</div>
<div class="product" data-price="89.99">
<h2 class="product-title">Headphones</h2>
<p class="description">High-quality wireless headphones</p>
<span class="price">$89.99</span>
</div>
</div>
</body>
</html>
"""
= BeautifulSoup(practice_html, 'html.parser')
soup
print(soup.prettify())
<html>
<body>
<div class="top-section" id="header">
<h1 class="main-title">
Welcome to Our Store
</h1>
<nav class="navigation">
<a href="/home">
Home
</a>
<a href="/products">
Products
</a>
<a href="/contact">
Contact
</a>
</nav>
</div>
<div id="main-content">
<div class="product featured" data-price="199.99">
<h2 class="product-title">
iPhone 15
</h2>
<p class="description">
Latest smartphone with amazing features
</p>
<span class="price">
$199.99
</span>
</div>
<div class="product" data-price="89.99">
<h2 class="product-title">
Headphones
</h2>
<p class="description">
High-quality wireless headphones
</p>
<span class="price">
$89.99
</span>
</div>
</div>
</body>
</html>