Semantic Tags Explained | Frontend Bootcamp Hindi | Ep.04

Anurag Singh ProCodrr
19 Sept 202212:00

Summary

TLDRThis video script delves into the concept of semantic HTML, emphasizing its importance for both developers and search engines. It explains that semantic tags like header, nav, main, section, and footer not only categorize content but also convey meaning, aiding in better SEO and accessibility. The script contrasts these with inline tags like span and div, illustrating their use for styling without semantic significance. It also touches on inline semantic tags like em and strong, which add emphasis to text. The video aims to educate viewers on the practical application of semantic HTML in web development for improved code readability and search engine optimization.

Takeaways

  • πŸ“š The video introduces the concepts of inline and block elements, and the use of 'span' and 'div' for categorizing content within a webpage.
  • πŸ”‘ 'Div' is used for grouping multiple elements into a section, while 'span' is for inline content.
  • 🌐 Semantic HTML is explained as the use of HTML tags that carry meaning and provide context to both the browser and developers.
  • πŸ” Semantic tags like 'nav', 'header', 'main', 'section', and 'footer' are highlighted as common examples, each serving a specific purpose in structuring a webpage.
  • 🎯 The 'header' tag is used to define the introductory content or navigation links of a webpage, helping search engines identify the site's header.
  • 🧭 The 'nav' tag is utilized for navigation links, indicating to search engines and screen readers that the content is for navigation.
  • 🏠 The 'footer' tag is designated for the bottom section of a webpage, which typically contains links and site descriptions.
  • πŸ“ The 'main' tag is used to enclose the primary content of a webpage, separate from headers and footers.
  • πŸ“‘ The 'section' tag is employed to define specific sections within the main content of a webpage.
  • πŸ–ŠοΈ Inline semantic tags like 'em' and 'strong' are used to emphasize text, with 'em' indicating emphasis and 'strong' signifying importance.
  • πŸ› οΈ Semantic HTML tags are not only beneficial for search engines but also improve code readability for developers and aid in understanding the webpage structure.

Q & A

  • What are the main differences between inline and block elements in HTML?

    -Inline elements do not start on a new line and only take up as much width as necessary. Block elements, on the other hand, start on a new line and take up the full width available, creating a 'block' on a page.

  • Why are the 'span' and 'div' elements used in HTML?

    -The 'span' element is used for inline styling or to group inline elements, while the 'div' element is used to categorize multiple elements in a section and is a block-level element.

  • What is semantic HTML and why is it important?

    -Semantic HTML refers to using HTML tags that have a meaning and provide context to the content, making it more accessible and understandable for both users and search engines.

  • What are some examples of commonly used semantic HTML tags?

    -Examples of commonly used semantic HTML tags include 'nav', 'header', 'main', 'section', and 'footer'.

  • How does using semantic HTML tags benefit search engines?

    -Semantic HTML tags help search engines understand the structure and content of a webpage, allowing them to index the page more effectively and improve its search ranking.

  • What is the purpose of the 'header' tag in HTML?

    -The 'header' tag is used to define the introductory content or navigation links of a page and groups elements like the logo, links, search bar, and buttons.

  • What is the role of the 'nav' tag in HTML?

    -The 'nav' tag is used to define a section of a page that contains navigation links, helping to group and identify the navigation elements.

  • How does the 'footer' tag contribute to the structure of a webpage?

    -The 'footer' tag is used to define the footer section of a webpage, typically containing links, information about the site, and a description.

  • What is the significance of the 'main' tag in the context of a webpage?

    -The 'main' tag is used to define the main content of a webpage, distinguishing it from other sections like the header, footer, and navigation.

  • What are some examples of block-level semantic HTML tags?

    -Examples of block-level semantic HTML tags include 'header', 'footer', 'nav', 'section', and 'main'.

  • What are the differences between the 'em' and 'i' tags in HTML?

    -The 'em' tag is used to emphasize text, making it semantically important and typically displayed as italicized text. The 'i' tag is used for a stylistic choice without semantic importance, also typically displayed as italicized text.

  • What is the purpose of the 'strong' tag in HTML?

    -The 'strong' tag is used to indicate that text is of strong importance, and it is typically displayed in bold to convey emphasis.

  • How do semantic HTML tags assist developers in understanding and maintaining code?

    -Semantic HTML tags provide clear context and meaning to the code, making it easier for developers to understand the purpose of different sections and maintain the codebase.

Outlines

00:00

πŸ“š Introduction to Semantic HTML

This paragraph introduces the concept of semantic HTML, explaining its importance and basic meaning. It distinguishes between inline and block elements, introduces the use of 'div' for categorizing elements and 'span' for inline elements. The paragraph also explains that semantic HTML tags like 'nav', 'header', 'main', 'section', and 'footer' carry specific meanings, aiding in the organization of web content, which is beneficial for search engines and accessibility tools. The example of MDN's website is used to illustrate how these tags are implemented in practice.

05:01

πŸ” The Role of Semantic HTML Tags in Web Development

The second paragraph delves deeper into the use of semantic HTML tags, emphasizing their role in assisting developers and search engines in understanding the structure and content of a webpage. It discusses the use of 'header', 'nav', 'footer', 'section', and 'main' tags as block-level semantic elements, which are alternatives to 'div' but with inherent meanings. The paragraph also introduces inline semantic tags like 'em' for emphasis and 'strong' for importance, explaining how they affect screen reader behavior and the readability of the code. The importance of using semantic HTML in projects for better code readability and search engine optimization is highlighted.

10:02

πŸ› οΈ Benefits of Semantic HTML for Developers and Search Engines

The final paragraph wraps up the discussion on semantic HTML by summarizing its benefits for both developers and search engines. It reiterates that semantic elements provide clear meaning to browsers, making the code easier to read and understand. The paragraph also touches on the fact that while it's possible to create a website using only 'div' tags, the use of semantic HTML is recommended due to its advantages in development and search engine comprehension. The video concludes with an encouragement to use semantic HTML in future projects for improved web development practices.

Mindmap

Keywords

πŸ’‘Inline and Block Elements

Inline and block elements are fundamental concepts in HTML that define how elements are displayed in the webpage layout. Inline elements, like 'span', do not start on a new line and only take up as much width as necessary. Block elements, such as 'div', start on a new line and stretch out to the full width of their parent element, creating a 'block' of content. In the script, the distinction between these elements is important for understanding the structural organization of web pages.

πŸ’‘Span and Div

Span and div are HTML elements used for different purposes. 'Span' is an inline element used to apply styles to a small portion of text within a block of text. 'Div' is a block-level element used to group larger sections of content. The script explains that 'div' is used to categorize multiple elements in a section, while 'span' is implied to be used for smaller, inline groupings.

πŸ’‘Semantic HTML

Semantic HTML refers to the use of HTML markup to reinforce the meaning and structure of the content, making it more accessible to both users and search engines. The script emphasizes that semantic HTML is not just about aesthetics but about conveying the purpose of the content through the use of appropriate tags, which helps search engines understand the page structure better.

πŸ’‘Meaning

In the context of the video, 'meaning' is associated with the semantic nature of HTML elements. Semantic elements have a clear meaning that is conveyed to both the browser and the developer, indicating the role or function of the content within the webpage. For example, 'header', 'nav', and 'footer' tags have specific meanings that are immediately recognizable in the structure of a webpage.

πŸ’‘Crawler

A crawler, in the context of search engines, is a program that automatically searches and indexes web pages. The script mentions Google's crawler to illustrate how semantic HTML helps these programs identify and categorize the different sections of a website, such as the header or footer, improving the site's search engine optimization (SEO).

πŸ’‘Navigation

Navigation is a key aspect of web design, allowing users to move between different pages or sections of a website. The 'nav' tag in semantic HTML is used specifically for navigation links, and the script explains that while it functions similarly to a 'div', it carries the meaning of being a navigation section, which is beneficial for both users and search engines.

πŸ’‘Screen Readers

Screen readers are software applications that convert text into synthesized speech or braille output for users who are visually impaired. The script discusses how semantic HTML helps screen readers understand the structure of a webpage, allowing them to convey the correct emphasis and importance to the user, such as reading the main content or navigation links distinctly.

πŸ’‘Main Content

The 'main' tag in semantic HTML is used to define the primary content of a webpage, separate from headers, footers, or navigation links. The script uses the 'main' tag as an example of how semantic elements help organize and identify the core content of a website, which is crucial for both accessibility and SEO.

πŸ’‘Section

The 'section' tag in semantic HTML is used to define a section of a document, such as a chapter, header, footer, or any other section of the page. The script mentions that the 'section' tag is used to highlight different parts of a website, providing a clear structure that aids in both readability and search engine indexing.

πŸ’‘Emphasis

Emphasis in HTML is used to indicate that a word or phrase is of importance within a sentence. The 'em' and 'strong' tags are semantic inline elements that carry meaning, with 'em' denoting a stressed emphasis and 'strong' indicating something of high importance. The script explains that these tags not only style the text but also convey semantic meaning, aiding screen readers in properly emphasizing the text when read aloud.

Highlights

Introduction to the use of div and span elements for categorizing and styling HTML content.

Explanation of semantic HTML as a concept that adds meaning to web content.

Semantic HTML helps search engines and screen readers understand the structure and purpose of web content.

Definition of 'semantic' as relating to meaning in language or logic.

Introduction of common semantic HTML tags such as nav, header, main, section, and footer.

Demonstration of how semantic tags like header and nav are used on MDN's website for better organization.

Clarification that semantic tags function similarly to div but with added meaning for search engines and accessibility tools.

Importance of using semantic HTML for SEO and improving the website's visibility to search engines.

Discussion on the use of footer tags to define and organize website footer content.

Explanation of the main tag's role in containing the primary content of a website.

Advantages of semantic HTML for developers, such as improved code readability and maintainability.

Introduction to block-level semantic HTML tags as alternatives to div for specific sections of a webpage.

Mention of inline semantic HTML tags like em and strong for emphasizing text within a sentence.

Difference between em and i tags, with em providing emphasis and i being a stylistic choice.

Explanation of the strong tag as an alternative to b for indicating importance in text.

Emphasis on the practicality of semantic HTML for both developers and search engine optimization.

Advice on using semantic HTML tags in development for better understanding and organization of code.

Conclusion summarizing the importance and application of semantic HTML tags in modern web development.

Transcripts

play00:00

Hi everyone, in the last

play00:02

video we saw what are

play00:04

inline and block elements

play00:06

and we introduced two new

play00:08

elements, span and div.

play00:10

In which case do we use these two elements?

play00:12

So basically we use

play00:13

div when we have

play00:15

to categorize multiple elements

play00:17

in a section.

play00:19

So we use div, div means division.

play00:23

And in this video we will

play00:25

learn what is semantic html?

play00:27

So semantic html sounds very hi-fi.

play00:31

But there is not much in it.

play00:33

The meaning of semantic is meaning.

play00:40

So the word semantic, if we see

play00:42

the meaning of semantic in English.

play00:44

So semantic means meaning.

play00:47

Semantic means meaning.

play00:50

If we come to our

play00:51

screen and search on Google.

play00:53

Semantic meaning.

play00:55

So see here, relating

play00:56

to meaning in

play00:58

language or logic.

play01:00

It means meaning.

play01:06

If we see in Hindi.

play01:08

So here its meaning is arth.

play01:11

So basically in html

play01:13

there are some tags

play01:15

which we use to

play01:17

work like div.

play01:19

We use them to categorize things.

play01:22

But they have some meaning.

play01:25

For example, if

play01:26

we take example

play01:28

of semantic elements.

play01:30

So there are some

play01:31

tags like nav tag,

play01:33

header tag, main tag,

play01:35

section tag, footer tag.

play01:37

So these are

play01:39

some commonly used

play01:41

semantic html tags.

play01:43

So if we come to MDN's website.

play01:46

And if we inspect its header.

play01:52

So we will see header tag.

play01:54

So basically what they have done is.

play01:56

All the elements in the header.

play01:58

Like this logo, links, search bar, button.

play02:05

So they have kept all

play02:07

these elements in a group.

play02:09

By using header tag.

play02:11

Basically this header tag

play02:13

works exactly like div.

play02:15

It does not add any

play02:16

extra functionality or anything.

play02:18

It just has its own name.

play02:22

So that if

play02:23

Google's crawler, Google's

play02:25

search engine.

play02:27

When it comes to search our website.

play02:30

So by looking at the header tag.

play02:32

It will immediately know that

play02:33

this is the website's header.

play02:35

Otherwise, if we use only

play02:36

div on the whole website.

play02:38

Then it will not be able to

play02:39

identify which is the header here.

play02:41

And then look inside this.

play02:43

Here they must have used nav tag.

play02:46

Like this link.

play02:48

So links are kept

play02:49

inside a nav tag.

play02:51

Because all these are related to navigation.

play02:54

So this is also exactly a div.

play02:56

It is a div, but

play02:57

the only difference is that.

play02:59

It carries its own meaning.

play03:02

That all the navigation links

play03:03

will be inside this.

play03:05

You can keep anything to keep.

play03:08

Keep an image, paragraph,

play03:09

text inside its nav.

play03:11

There will be no difference in looking.

play03:13

But then if you keep anything.

play03:15

The search engine will be confused.

play03:18

So that's why we have

play03:19

to use it exactly

play03:21

where the tag is

play03:23

made to be used.

play03:25

This semantic html.

play03:27

So these are the two

play03:29

tags, header and nav tags.

play03:31

Then if we come down here.

play03:34

So this is the footer of a website.

play03:36

Every website has a section below.

play03:39

Where there are some links.

play03:41

And there is a little

play03:42

bit about the site.

play03:44

And there is a little description of it.

play03:46

So that section is called footer.

play03:48

So technically we can keep it inside the div.

play03:50

You can give it a little background color.

play03:52

You can style anything.

play03:54

You can keep it in the div.

play03:55

There will be no problem.

play03:56

If you look visually,

play03:57

there is no problem.

play03:59

There will be no difference in looking.

play04:01

But the Google search engine

play04:03

will not be able to

play04:05

find out where the footer

play04:07

is in this website.

play04:09

So that's why we should

play04:10

use the footer tag.

play04:12

So it just groups it.

play04:14

So this is the footer tag.

play04:17

We put the footer of

play04:18

the website in it.

play04:20

So this is the third one.

play04:22

If we look here.

play04:24

So there may be some

play04:26

other semantic html tags.

play04:28

For example, look here, this is main.

play04:31

So inside the main tag, we keep

play04:33

the entire content of the website.

play04:35

We don't keep a header there.

play04:37

The header is separate

play04:39

from the main content.

play04:41

You can keep anything to keep anywhere.

play04:44

There will be no problem in looking.

play04:46

There will be no problem in using the user.

play04:48

There are also screen readers

play04:50

for the search engine.

play04:53

For example, those who

play04:55

can't see, they use

play04:57

some software, screen readers.

play04:59

So that software finds out that there

play05:01

is a link here, there is a

play05:03

header here, there is a footer

play05:05

here, there is main content here.

play05:07

If I want to read something, I

play05:08

will find it in the main tag.

play05:10

So all these tags

play05:12

and semantics help

play05:14

the software to

play05:16

understand our page.

play05:18

Now that software can be a screen reader.

play05:20

That software can also be

play05:21

a Google search engine.

play05:23

So yes, the main was here.

play05:27

We saw that this is the main.

play05:29

Inside the main, we

play05:30

keep the actual full

play05:32

content of our website.

play05:34

Ideally, you can keep anything.

play05:37

There will be no problem.

play05:39

But we don't do this.

play05:41

This is not considered a good practice.

play05:43

And then we come here, so there is a section.

play05:45

Here they have

play05:46

used div and

play05:48

then section.

play05:50

The section also

play05:52

highlights a section

play05:54

of the website.

play05:56

This is one section of the website, this is the second section.

play05:58

Similarly, there are

play05:59

many tags in

play06:01

semantic html.

play06:03

What we have seen

play06:04

so far, all

play06:06

those semantic tags

play06:08

are block-level tags.

play06:10

These are exactly the alternatives of div.

play06:13

Where we have to use

play06:15

div, but we also have

play06:17

to carry some specific meaning.

play06:19

So we use all these.

play06:22

Like header, footer, nav, section, main.

play06:26

So I counted 4-5, there are more.

play06:29

If we

play06:30

come here,

play06:32

we will

play06:34

search for

play06:36

semantic html

play06:38

tags.

play06:43

So there are many tags.

play06:46

You don't have to remember

play06:47

any of these tags.

play06:49

Not even what I have told you.

play06:50

Not even what is written here.

play06:52

Just read it once and see

play06:53

that yes, something like this happens.

play06:55

When we make actual projects,

play06:56

we will use it there.

play06:58

Gradually, you will remember what to use and where.

play07:00

So these are all

play07:02

block-level semantic html tags.

play07:04

Which we use instead of div.

play07:06

But there are also

play07:08

some semantic inline tags.

play07:10

Two of them are used the most.

play07:14

They are tag and tag.

play07:17

If we come here and see.

play07:19

tag in html.

play07:22

So see what tag does.

play07:29

Let's see the result of w3schools.

play07:33

So em has a full form.

play07:37

Emphasis.

play07:39

If we want to emphasize a word.

play07:45

So we use tag.

play07:49

What does it do?

play07:51

It makes the text slanted.

play07:55

We used it using tag.

play07:58

In the last video, we used itag.

play08:02

I used tag and ran it.

play08:04

There was no difference.

play08:06

It is exactly the same.

play08:07

So itag does not carry any meaning.

play08:11

It is just a stylistic choice.

play08:13

If you want to

play08:14

make something slanted in

play08:16

the whole sentence.

play08:18

But the user is reading.

play08:20

You don't want to emphasize it.

play08:22

So you use itag.

play08:24

But emtag emphasizes it specifically.

play08:28

So when the screen reader is reading.

play08:31

It pronounces it slightly differently.

play08:34

So that the word can be emphasized.

play08:37

So this is tag.

play08:40

And then there is tag.

play08:43

tag is exactly the alternative to tag.

play08:57

So here I wrote strong.

play09:00

And this text is bold.

play09:02

So this is also emphasizing a word.

play09:11

So if we search.

play09:15

tag.

play09:17

tag in html.

play09:21

So what does tag do?

play09:25

It defines important text.

play09:28

In the document.

play09:30

So if we have a whole paragraph.

play09:32

So we can

play09:33

use tag on

play09:35

the important word.

play09:37

So these two tags.

play09:39

tag and tag.

play09:42

They carry a meaning with them.

play09:44

Emphasize this word.

play09:46

This is an important

play09:47

word of our sentence.

play09:50

Semantic tags are not

play09:52

only for search engines.

play09:54

As a developer, they also help us.

play09:57

For example, if we see header tag.

play09:59

We will immediately know that

play10:00

this is the website header.

play10:02

If we see footer tag.

play10:04

We will immediately know that

play10:05

this is the website footer.

play10:07

And if we see main tag.

play10:09

We will know that the main content

play10:10

of the website is in this tag.

play10:12

So not only for software.

play10:15

As a developer, it is easy

play10:16

for us to read code.

play10:18

When we use semantic html

play10:20

tags in our code.

play10:22

So when we do development.

play10:24

We will try to use

play10:26

semantic html tags wherever possible.

play10:28

So if we

play10:29

come to the

play10:31

website of W3schools.

play10:33

So here is the same

play10:35

definition of semantic html.

play10:37

A semantic element clearly describes

play10:38

its meaning to both

play10:40

browser and the developer.

play10:42

So it also

play10:43

carries meaning to

play10:45

the browser.

play10:47

So the semantic tag also

play10:49

tells the browser which section

play10:51

of the website it is.

play10:53

And it also helps

play10:54

us as a developer.

play10:56

So we saw what are semantic tags.

play10:59

Semantic tags are exactly like divs.

play11:02

There will be no difference in functionality.

play11:05

As a developer, it will be

play11:06

easy for us to read code.

play11:08

And it will be easy

play11:09

for the browser and

play11:11

search engines to understand.

play11:13

So if we want, we can make

play11:15

the whole website using only divs.

play11:17

In fact, there are

play11:18

many websites in production.

play11:20

Which are made using only

play11:21

divs and are running well.

play11:23

But when we use.

play11:26

We will use semantic html tags.

play11:29

Because it helps us as a developer.

play11:33

And also helps the search

play11:35

engine to understand the page.

play11:37

So let's quickly conclude this video.

play11:39

In this video, we saw

play11:40

what are semantic html tags.

play11:42

And when we should use those tags.

play11:45

So I hope you understood

play11:47

the semantic tags well.

play11:49

So that's all for this video.

play11:50

See you in the next video.

play11:52

Bye Bye.

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
Semantic HTMLSEO TipsWeb AccessibilityHTML TagsDiv UsageScreen ReadersWeb DevelopmentContent StructuringHTML5Google Crawler