Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Classes and Ids | Getting Acquainted with HTML
Web Scraping with Python
course content

Contenido del Curso

Web Scraping with Python

Web Scraping with Python

1. Getting Acquainted with HTML
2. Beautiful Soup: Part I
3. Beautiful Soup: Part II

book
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.

html

index.html

css

styles.css

copy

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.

html

index.html

css

styles.css

copy

It's important to remember that the id must be unique on the page. You cannot use the same id value for multiple elements.

Choose the correct statements.

Choose the correct statements.

Selecciona unas respuestas correctas

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 6
We're sorry to hear that something went wrong. What happened?
some-alt