Python Tutorial: HTML Tags and Attributes
Skills:
LLM Foundations80%
Key Takeaways
This video tutorial covers HTML tags and attributes, focusing on the general abstract structure of HTML tags, including tag names and attributes, with a special emphasis on ID, class, and href attributes, using Python for web scraping.
Full Transcript
in the last lesson we became familiar with the tree-like structure of HTML and learned how to navigate the tree to access specific elements we did not pay much attention to the actual HTML tags nor the specifics of HTML syntax beyond this tree like structure in this lesson we delve deeper into some of the HTML specific syntax you may ask why we want to get more specific here it turns out that sometimes we want to access information that is held within the HTML tags themselves we often want to access this info in order to find the URL pointed to by a specific link on the site or because it can potentially give us another method to select specific HTML elements with a more friendly syntax than traversing the entire HTML tree to start let's look at an abstract tag formatting there are many HTML tag types that follow the same formatting we have already seen 3 tag names the HTML div and P tags these tags can also contain attributes which provide special instructions for the contents contained within that tag specific HTML attribute names are followed by an equal sign followed by information which is being passed to that attribute within the tag in well formatted HTML the information is in quotes sound confusing don't worry to look at a specific example let's consider a div tag with two attributes ID and class we chose these two attributes here because they arise frequently in practice in well form HTML the ID attribute can be used as a unique identifier for the tag element in this case the ID unique ID should only belong to this specific develoment giving us a quick way to identify it the class attribute some class can also help us identify this div element but even in well formatted HTML it doesn't need to be unique note tag needs to have an ID nor a class attribute but all tags can be given an ID and a class a point that will find its way into a future lesson is that a tag can belong to multiple classes and this is done when the class attribute that is the quoted text assigned for that class has multiple class names separated by spaces in fact this div tag would belong to both classes sum and class let's look at another example the a tag name here is the specific tag for hyperlinks the links we click on within a website to redirect somewhere the most important attribute within these hyperlink tags is the href attribute this attribute is used to identify the URL where the hyperlink redirects - it turns out that there are many allowable tag types in HTML and many allowable attributes which sometimes depend on those tag types we will not be able to nor want to go through each and every one of these in this course rather we're going to learn techniques that will be applicable regardless of the tag with a special focus on ID class and href attributes we saw in this lesson building up methods that can easily apply to other attributes as you encounter them and don't worry even with only those three attributes we will get a lot of traction so what did we learn in this lesson we focused on HTML specific syntax learning the general abstract structure of HTML tags we saw how to identify the tag naman attributes within those tags now let
Original Description
Want to learn more? Take the full course at https://campus.datacamp.com/courses/web-scraping-with-python/ at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
--
In the last lesson, we became familiar with the tree-like structure of HTML, and learned how to navigate the tree to access specific elements. We did not pay much attention to the actual HTML tags, nor the specifics of HTML syntax beyond this tree-like structure. In this lesson, we delve deeper into some of the HTML-specific syntax.
You may ask why we want to get more specific here? It turns out that sometimes we want to access information that is held within the HTML tags themselves -- we often want access this info in order to find the URL pointed to by a specific link on the site, or because it can potentially give us another method to select specific HTML elements with a more friendly syntax than traversing the entire HTML tree.
To start, let's look at an abstract tag formatting.
There are many HTML tag types that follow the same formatting; we have already seen three tag names: the html, div, and p tags.
These tags can also contain attributes which provide special instructions for the contents contained within that tag. Specific html attribute names are followed by an equals sign, followed by information which is being passed to that attribute within the tag; in well-formatted HTML the information is in quotes. Sound confusing? Don't worry!
To look at a specific example, let's consider a div tag with two attributes: id and class. We chose these two attributes here because they arise frequently in practice. In well-formatted HTML, the id attribute can be used as a unique identifier for the tag element; in this case, the id "unique-id" should only belong to this specific div element, giving us a quick way to identify it. The class attribute "some class" can also help us identify this div element, but even in well-formatted HTML, it doesn't nee
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DataCamp · DataCamp · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
More on: LLM Foundations
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Claude AI vs ChatGPT: Which One Is Actually Better in 2026?
Medium · AI
Claude AI vs ChatGPT: Which One Is Actually Better in 2026?
Medium · Programming
IntelliBooks: Classic RAG vs Graph RAG vs Agentic RAG – Choosing the Right AI Retrieval Architecture for Enterprise AI
Dev.to AI
Fluid, natural voice translation with Gemini 3.5 Live Translate
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI