Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Attributes | HTML Files and DevTools
Web Scraping with Python (res)

bookAttributes

We have already considered some popular tags (html, body, head, p, h1). These tags can also contain attributes - strings in tags that provide us with additional information about code in tags. The attribute in a tag is followed by an equals sign, followed by information about that attribute in the tag code. For example:

<div id = "2" class = "class1">
…
</div>

There is a div tag with 2 extremely common attributes: id and class. Here the id is a unique identifier to our tag, which helps to find it. The attribute id should be used once for one tag. The attribute class doesn’t need to be unique as this specifies which class belongs to the tag. Many tags can belong to the same class. The tag can also belong to multiple classes (multiple class names will be separated by spaces).

You can also look at the pages we worked with to see their attributes.

The tag <a> defines a hyperlink. The attribute href help to define the URL of the website where the link goes:

<a href = "https://codefinity.com/">Visit Codefinity!</a>

The result:

There are many different tag types and attributes (depending on the tags they belong to). We will not go through all these tags! In the following chapters, we will explore methods to help us find information using attributes.

question mark

Which attribute do we use for the hyperlink?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 6

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

Still meg spørsmål om dette emnet

Oppsummer dette kapittelet

Vis eksempler fra virkeligheten

Awesome!

Completion rate improved to 4.76

bookAttributes

Sveip for å vise menyen

We have already considered some popular tags (html, body, head, p, h1). These tags can also contain attributes - strings in tags that provide us with additional information about code in tags. The attribute in a tag is followed by an equals sign, followed by information about that attribute in the tag code. For example:

<div id = "2" class = "class1">
…
</div>

There is a div tag with 2 extremely common attributes: id and class. Here the id is a unique identifier to our tag, which helps to find it. The attribute id should be used once for one tag. The attribute class doesn’t need to be unique as this specifies which class belongs to the tag. Many tags can belong to the same class. The tag can also belong to multiple classes (multiple class names will be separated by spaces).

You can also look at the pages we worked with to see their attributes.

The tag <a> defines a hyperlink. The attribute href help to define the URL of the website where the link goes:

<a href = "https://codefinity.com/">Visit Codefinity!</a>

The result:

There are many different tag types and attributes (depending on the tags they belong to). We will not go through all these tags! In the following chapters, we will explore methods to help us find information using attributes.

question mark

Which attribute do we use for the hyperlink?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 6
some-alt