Зміст курсу
Web Scraping with Python
Web Scraping with Python
Classes and Ids
HTML has a limited number of tags, but sometimes you need to differentiate between specific elements. For example, if you want to apply different styles to various paragraphs (<p>
elements), you can use the class
and id
attributes.
The class
attribute assigns a class to a specific HTML element. Multiple elements can share the same class. This allows you to apply the same styles to multiple elements.
index.html
styles.css
In this example, two paragraphs share the same highlight
class, allowing you to apply the same styles to both.
The id
attribute assigns a unique identifier to a specific HTML element. Unlike the class
attribute, each element can only have one unique id
. This is useful for applying styles or manipulating a specific element using JavaScript.
index.html
styles.css
It's important to remember that the id
must be unique on the page. You cannot use the same id
value for multiple elements.
Дякуємо за ваш відгук!