Inline Vs Block Elements | Div & Span Tags Explained | Frontend Bootcamp Hindi | Ep.03

Anurag Singh ProCodrr
18 Sept 202224:02

Summary

TLDRIn this educational video, viewers are introduced to the concepts of inline and block elements in HTML, essential for web development. The tutorial begins by explaining the difference between the two, highlighting that block elements like 'h1' and 'p' tags take up the full width of their container, while inline elements such as 'b', 'i', and 'a' only occupy the space required by their content. The presenter demonstrates how to identify these elements using browser developer tools and provides practical examples by modifying a simple website. Additionally, the video introduces the 'span' and 'div' tags, explaining their common uses for inline and block-level content styling, respectively. The session concludes with a teaser for the next lesson on semantic HTML tags, promising further insights into web design and layout creation.

Takeaways

  • 🌐 The video script is a tutorial that builds on a previous lesson about basic HTML tags and introduces the concepts of inline and block elements.
  • πŸ”— The anchor tag is highlighted as an example of an inline element, which has a width equal to its content and does not start on a new line after the element.
  • πŸ“ Block elements, such as the H1 tag, are explained to have a default width of 100%, causing them to span the entire width of their container and start on a new line.
  • πŸ•΅οΈβ€β™‚οΈ The script instructs viewers on how to inspect elements in a web browser to determine if they are inline or block by checking the 'display' property.
  • πŸ“š The tutorial demonstrates the difference between inline and block elements by showing how they behave differently in a webpage layout.
  • πŸ› οΈ The script provides a practical example of how to modify an existing HTML project to understand the application of inline and block elements.
  • πŸ–ŒοΈ The 'span' tag is introduced as a commonly used inline element for applying styles to a specific part of text without affecting the layout.
  • πŸ”² The 'div' tag is introduced as a commonly used block element for dividing the page into sections and is often used for styling and layout purposes.
  • 🎨 The video shows how to apply background colors to text and sections of a webpage using inline and block elements, and the importance of understanding element types for styling.
  • πŸ”„ The tutorial explains how to use the 'auto rename tag' extension in VS Code to easily match opening and closing tags, improving coding efficiency.
  • 🌐 The script concludes by emphasizing the importance of understanding HTML structure and element types in preparation for learning CSS and creating webpage layouts.

Q & A

  • What are the basic HTML tags covered in the last video?

    -The basic HTML tags covered include anchor tags for adding links, bold and italic tags for text formatting, and tags for adding bullet points and numbered lists.

  • What is the main focus of the current video script?

    -The main focus is to understand the concepts of inline and block elements in HTML, their uses, and the problems they solve.

  • How can you inspect an HTML element to see if it is inline or block?

    -You can inspect an HTML element by right-clicking on it and selecting 'Inspect', then looking at the 'Computed' tab and filtering for the 'display' property to see if it says 'block' or 'inline'.

  • What is the default width of block elements?

    -The default width of block elements is 100%, meaning they take up the full width of their containing element.

  • How does the width of inline elements differ from block elements?

    -The width of inline elements is only equal to the content within them, unlike block elements which default to 100% width.

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

    -The 'span' tag is an inline element used to apply styles to a specific part of the text without affecting the layout or structure of the document.

  • What is the 'div' tag used for in HTML?

    -The 'div' tag, short for division, is a block element used to create a section or division in a webpage, often to group and style content collectively.

  • Why is the 'div' tag considered essential in web layout design?

    -The 'div' tag is essential because it allows developers to group elements together and apply styles to them as a collective, which is fundamental in creating structured and styled web layouts.

  • What is the advantage of using the 'span' tag over other inline elements for styling text?

    -The advantage of using the 'span' tag is that it doesn't change the text's appearance or layout by default, allowing developers to apply specific styles to a small section of text without affecting other elements.

  • How can you quickly duplicate a 'div' element in HTML?

    -You can quickly duplicate a 'div' element by selecting it and using the keyboard shortcut 'Shift + Alt + Down Arrow'.

  • What is the script's suggestion for the next topic to be covered in the video series?

    -The next topic to be covered is semantic tags in HTML, discussing their use and benefits.

Outlines

00:00

🌐 Understanding Inline and Block Elements

This paragraph introduces the concept of inline and block elements in HTML, explaining their uses and the problems they solve. The instructor revisits a previous project to demonstrate these elements in practice. Inline elements, such as the bold and anchor tags, are shown to have a width equal to their content, while block elements, like the H1 tag, span 100% of the container's width by default. The use of developer tools to inspect elements and understand their display properties is also covered.

05:01

πŸ“ Exploring Inline Elements and Text Formatting

The instructor discusses the behavior of inline elements, using bold and italic tags as examples, and how they flow directly in line with other content. The paragraph tag's default width of 100% is contrasted with inline elements that adjust their width to the content. The concept is further illustrated by manipulating text alignment and background colors to show how block elements cover the full width, while inline elements do not. The segment ends with a tip on using the 'auto rename tag' extension in VS Code for easier coding.

10:02

🎨 Styling Text with Inline Elements

This section delves into how to style specific text within a line using inline elements like 'span' and 'i' tags. The 'span' tag is highlighted as a versatile inline element that can be styled differently from the surrounding text without affecting the layout. The instructor demonstrates changing text color to green and making text bold and italic, emphasizing the 'span' tag's role in applying unique styles to small sections of text.

15:03

πŸ–ΌοΈ Utilizing Block Elements for Layout Division

The paragraph focuses on block elements, particularly the 'div' tag, which is used to create sections and apply styles to grouped content. The 'div' is described as a container that can hold multiple elements and allow for styling of an entire section. The instructor shows how to change the background color of a section by styling a 'div', and how to use transparent images to reveal background colors. The concept of division is emphasized as a way to separate different parts of a webpage.

20:05

πŸ“š Organizing Content with Div and Span Tags

The final paragraph wraps up the lesson by summarizing the roles of 'div' and 'span' tags in HTML. The 'div' is portrayed as essential for dividing a page into sections and the 'span' for applying unique styles to small text segments. The instructor previews the next topic, semantic tags in HTML, and their benefits. The video concludes with a reminder of the importance of 'div' and 'span' tags in web development and an invitation to the next video in the series.

Mindmap

Keywords

πŸ’‘HTML

HTML, or HyperText Markup Language, is the standard language used to create and design websites. It defines the structure and layout of a web page by using various tags and attributes. In the video, HTML is the central theme as the script discusses the creation of a website and the use of HTML tags to format the content.

πŸ’‘Inline Elements

Inline elements in HTML are those that do not start on a new line and only take up as much width as necessary to contain their content. Examples of inline elements mentioned in the script include 'b' for bold and 'i' for italics. The script explains that inline elements are used within block elements and do not break the flow of the content.

πŸ’‘Block Elements

Block elements in HTML start on a new line and, by default, take up the full width available to them, which is typically 100% of their parent element. The script uses 'p' for paragraphs and 'h1' for headings as examples of block elements, demonstrating how they create distinct sections on a webpage.

πŸ’‘Anchor Tag

The anchor tag in HTML is used to create hyperlinks. It is mentioned in the script as an inline element that allows users to navigate to different pages or sections by clicking on text or images. The script explains how to use the anchor tag to add links to a webpage.

πŸ’‘CSS

CSS, or Cascading Style Sheets, is used for describing the presentation of a document written in HTML. The script mentions CSS in the context of changing the appearance of HTML elements, such as making text green or setting background colors, which will be covered in more depth in future lessons.

πŸ’‘Span Tag

The span tag is an inline element in HTML used to apply styles to a specific part of the text without affecting the surrounding content. The script explains that span does not have any inherent styling of its own but can be targeted with CSS to change the style of the text it wraps.

πŸ’‘Div Tag

The div tag is a block element in HTML used to create a division or a section in the layout of a webpage. The script discusses how divs are used to group and style multiple elements together, making them a fundamental part of web design for creating structured layouts.

πŸ’‘Display Property

The display property in CSS is used to define how an HTML element should be displayed on a page. The script refers to the display property when explaining the difference between inline and block elements, showing how elements like 'b' and 'i' are displayed inline by default, while 'p' and 'h1' are block elements.

πŸ’‘Live Server

Live Server is a feature in some code editors, such as VS Code, that allows developers to open their web projects directly in a browser and see the changes they make in real-time. The script mentions opening a project with the Live Server to view the HTML elements and their effects on the webpage layout.

πŸ’‘Semantic Tags

Semantic tags in HTML are elements that provide meaning to the web content rather than just presentation. Although not fully explained in the script, the mention of semantic tags suggests that they will be discussed in a future video, likely in the context of improving accessibility and SEO.

Highlights

Introduction to inline and block elements in HTML and their uses.

Explanation of how to identify inline and block elements using developer tools.

Demonstration of the default 100% width behavior of block elements like H1 and p tags.

Illustration of inline elements having width equal to their content, such as bold and anchor tags.

Use of the 'display' property to filter and identify block elements in the computed tab.

Introduction of the span tag as a commonly used inline element for applying styles to text.

The div tag is introduced as a block element used for dividing sections on a webpage.

Explanation of how to apply background color to specific sections using the div tag.

The use of transparent images to show background colors applied via CSS.

The concept of grouping elements within a div for styling and layout purposes.

The importance of div tags in creating layouts and their widespread use in web development.

Practical tip on using the 'auto rename tag' extension for HTML editing in VS Code.

How to manipulate text styling within inline elements without affecting layout.

The difference between inline and block elements in terms of layout and styling.

The role of the CSS 'style' attribute in applying direct styles to HTML elements.

How to use the live server in VS Code for real-time preview of HTML changes.

The impact of removing text-align center property on the layout of block elements.

Overview of semantic tags in HTML and their benefits for SEO and accessibility.

Transcripts

play00:00

Hi everyone, in the last

play00:01

video, we made a small

play00:03

website on front-end roadmap.

play00:05

And while making that website,

play00:07

we learned basic HTML tags.

play00:09

For example, how to

play00:10

use anchor tag

play00:12

to add links,

play00:14

how to bold, how to italicize text,

play00:17

how to add bullet points,

play00:19

how to add numbered list.

play00:21

So, we learned

play00:23

some commonly used

play00:25

basic HTML elements.

play00:27

In this video, we will understand

play00:29

what are inline and block elements,

play00:30

what are their uses, and

play00:32

what problems they solve.

play00:34

So, let's go to our screen.

play00:36

I have come to the same folder

play00:38

where we created the last project.

play00:40

I will copy and paste it here,

play00:42

that is, I will duplicate this folder.

play00:44

And I

play00:46

will name

play00:48

it inline

play00:50

vs

play00:52

block

play00:54

elements.

play00:59

Let's make it 03.

play01:02

We will use the same project

play01:04

to understand inline and block elements.

play01:06

So, here we will right-click

play01:08

and open with VS Code.

play01:11

So, it has opened

play01:13

in my VS Code.

play01:15

Now, I will

play01:17

right-click and open

play01:19

with live server.

play01:21

It has opened with my live server.

play01:24

So, we made this website

play01:26

in the last lecture.

play01:28

So, we will understand

play01:29

here that whatever

play01:31

we have created,

play01:33

some elements are inline and

play01:35

some elements are block.

play01:37

So, which one is inline

play01:38

and which one is block?

play01:40

So, if we want to see it

play01:42

ourselves, how will we see it?

play01:44

For example, if

play01:46

we click on

play01:47

this and inspect,

play01:49

then our elements tab will open.

play01:51

And then there is

play01:53

a computed tab here.

play01:54

If we come to

play01:56

this, we can see

play01:57

the display block above.

play01:59

There are many other things that are

play02:01

visible, so put a filter here.

play02:02

DISP...

play02:04

So, I have

play02:06

put a filter

play02:08

for display block.

play02:09

So, I can see only this property.

play02:11

And its value is block.

play02:13

So, this is block.

play02:15

So, this is a block element.

play02:17

So, which inline elements are here?

play02:19

So, this is the inline element here.

play02:21

For example, if we go to the bold tag,

play02:23

we will see that

play02:25

inline is written here.

play02:26

So, this is inline.

play02:28

There is another anchor tag

play02:30

which is an inline element.

play02:33

So, what is the difference between these two?

play02:35

Look carefully.

play02:37

This bold element has

play02:39

the same width

play02:41

as its content.

play02:43

But look at its width.

play02:45

The width of H1 is

play02:46

going from here to here.

play02:48

If you look here,

play02:50

its width will also be written here.

play02:52

So, its width is 677.

play02:55

So, its width is equal to this.

play02:58

It is almost equal to this.

play03:01

So, by default,

play03:03

the width of block elements is 100%.

play03:05

Even if you write a little content in it,

play03:07

even if you write only one letter,

play03:09

even if you write the whole line,

play03:11

its width will always be 100%.

play03:13

So, for example, this is a p tag.

play03:15

Its width is 100%.

play03:17

And this is a display block.

play03:19

So, the width of inline elements is

play03:22

only equal to the content in it.

play03:26

So, look at this.

play03:29

This anchor tag is also an inline element.

play03:31

And its width is the same.

play03:33

If you look here,

play03:35

its width is the same as its content.

play03:37

And if we come here and look at the image,

play03:39

the image is also of an inline type.

play03:41

Display inline.

play03:43

So, all these elements are display inline.

play03:47

Which images are inline?

play03:49

This bold tag is inline.

play03:51

This anchor tag is inline.

play03:53

And if we come here,

play03:55

the italic tag, i tag,

play03:58

this one is also display inline.

play04:00

So, all these are inline elements.

play04:02

Its width is only equal to

play04:04

the content in it.

play04:06

So, these are inline elements.

play04:08

We will study this in great detail

play04:10

when we study CSS.

play04:12

Then we will study it in more detail.

play04:14

And we will see how

play04:16

we can make an inline element a block

play04:18

and we can change the block

play04:20

inline by giving its property.

play04:22

So, for a minute,

play04:24

we will remove all this content.

play04:26

Remove everything.

play04:28

Remove the lower part

play04:30

and keep the upper part.

play04:32

So, how much?

play04:34

Remove the whole UL.

play04:38

So, I removed this much.

play04:40

I have this much left.

play04:42

Only this much is left.

play04:44

So, under this p tag,

play04:46

we will write some inline elements.

play04:48

So, if I press ctrl enter here,

play04:50

my cursor will automatically

play04:52

come to the next line.

play04:54

I also had a cursor here.

play04:56

If I press ctrl enter,

play04:58

it comes to the next line.

play05:00

There is no need to take the cursor

play05:02

behind the whole line.

play05:04

It will automatically come to the next line

play05:06

if you press ctrl enter.

play05:08

So, I always use the same shortcut.

play05:10

So, here we will write some inline elements.

play05:12

For example, I wrote b,

play05:14

meaning bold tag.

play05:16

Here I will write hello

play05:18

world.

play05:20

So, here I have

play05:22

hello world.

play05:24

Now, under this,

play05:26

I will write

play05:28

what should I write here?

play05:30

Under this, I will write

play05:32

an i tag.

play05:34

Here, I will write

play05:36

hello world 2.

play05:38

So, see here, one by one,

play05:40

it is coming in a line immediately.

play05:42

It ends here,

play05:44

then it comes here immediately.

play05:46

But, if we

play05:49

remove the text align center,

play05:51

then this p tag will come here.

play05:55

Here, it was text align center,

play05:57

so it was coming here.

play05:59

We have removed the text align center property.

play06:01

So,

play06:03

it will come in the starting from here.

play06:05

So, see this p tag

play06:07

is covering the whole width.

play06:09

If we inspect here,

play06:11

it is covering the whole width.

play06:13

If we want,

play06:15

we can also see the background color here.

play06:17

So, style is equal to

play06:19

background color.

play06:21

You don't have to remember this.

play06:23

This is a CSS property.

play06:25

You just have to write

play06:27

this much for now.

play06:29

We will give the background color as pink.

play06:31

Let's say we give it pink.

play06:33

So, we gave it pink.

play06:35

So, its content is up to here.

play06:37

But, the element

play06:39

is spread all the way to here.

play06:41

It is spread all the way to here.

play06:43

From here to here.

play06:45

So, by default,

play06:47

its width is 100%.

play06:49

It covers the whole body's width.

play06:51

Body's width

play06:53

is all the way from here to here.

play06:55

From start to end.

play06:57

From here to here.

play06:59

Why it is not going all the way?

play07:01

When we will read the CSS,

play07:03

we will see it clearly.

play07:05

As you can see,

play07:07

there is a margin on the body.

play07:09

8 pixels.

play07:11

That margin is stopping it

play07:14

If we will remove the margin from the body,

play07:16

it will reach to the edge by default.

play07:18

Because its width

play07:20

is 100% by default.

play07:22

But, if we give the background color

play07:24

to this.

play07:26

Let's copy the same thing

play07:28

and change the color.

play07:30

What did I copy?

play07:37

Let's change it to hot pink.

play07:39

Hot pink

play07:41

is a color in CSS.

play07:43

It looks like this.

play07:45

We have not given

play07:47

any width to it.

play07:49

Still, its width is the same

play07:51

as the content.

play07:53

Because it is inline.

play07:55

See here.

play07:57

This is inline.

play07:59

Display inline.

play08:01

And this p tag is display block.

play08:03

So, this is the difference.

play08:05

The width of inline elements

play08:07

is equal to its content.

play08:09

And if there is

play08:11

a new inline element in front of it,

play08:13

it will come immediately.

play08:15

Here, the content is over.

play08:17

I put another inline element in front of it.

play08:19

It came immediately.

play08:21

We saw that images

play08:23

are also inline elements.

play08:25

If we put the image here,

play08:27

if we copy and paste

play08:29

the image here,

play08:31

it will come immediately after that.

play08:33

It will not come in the next line.

play08:35

See here, this is hello world.

play08:37

This is hello world 2.

play08:40

This is the image.

play08:42

If I reduce its width,

play08:44

then it will come

play08:46

in the new line.

play08:48

There is no space for its width.

play08:50

That is why it is in the next line.

play08:52

By default, it is in the same line.

play08:54

See here, it is in the same line.

play08:56

This is 1, this is 2, this is 3.

play08:58

If I remove the image from here,

play09:00

where is the image?

play09:02

If I remove the image and

play09:04

put a block element,

play09:06

like p tag, h1, h2,

play09:08

all of them are block elements.

play09:10

I will put h2 here.

play09:12

I will write welcome here.

play09:16

See here,

play09:18

there is so much space here.

play09:20

There is so much space after this.

play09:22

But welcome is coming

play09:24

in the next line.

play09:29

See here.

play09:31

What happened now is that

play09:33

I changed

play09:35

its tag name,

play09:37

but it did not end.

play09:39

It came here

play09:41

and was doing

play09:43

this.

play09:45

The HTML engine

play09:47

did not know

play09:49

where the i tag

play09:51

ended.

play09:53

After that, it is making

play09:55

welcome italic.

play09:57

If we close this,

play09:59

it will automatically

play10:01

get fixed.

play10:03

There is an extension for this.

play10:05

If I make it bold,

play10:07

we will have to change

play10:09

the tag at the back.

play10:11

There is an extension

play10:13

auto rename tag.

play10:15

If we go here,

play10:17

auto

play10:19

rename,

play10:21

auto rename tag.

play10:23

We will install it.

play10:25

It worked.

play10:27

If I make it bold,

play10:29

it will change automatically.

play10:31

See here.

play10:34

If I make it p tag,

play10:36

it will also be p tag.

play10:38

This is a small quick tip

play10:40

which you can follow.

play10:42

By installing this extension,

play10:44

your life will be easy.

play10:48

I put h2 here.

play10:50

It is coming in the new line

play10:52

because it is a block element.

play10:54

We will remove all these.

play10:56

We will now

play10:58

see about two new tags

play11:00

which are used on every website.

play11:02

Most of the websites

play11:04

use the same two tags.

play11:06

For example,

play11:08

if I

play11:10

want to

play11:12

make this website

play11:14

green.

play11:16

I want to make it green.

play11:18

How will I do that?

play11:20

First,

play11:24

I will remove this.

play11:26

I want to make it green.

play11:28

I can do one thing.

play11:30

First, let's see

play11:32

how to give color to any text.

play11:34

If I come here

play11:36

and style color

play11:38

equal to

play11:40

green,

play11:42

the whole line will be green.

play11:44

From here to here.

play11:46

The anchor tag is not green

play11:48

because it has its own color.

play11:50

That is why it is not green.

play11:52

The whole line is green.

play11:54

But I don't want to make the whole line green.

play11:56

I just want to make

play11:58

this text green. Only the website text.

play12:01

play12:03

So, if I have to make this green,

play12:04

how will I do it?

play12:06

Do you have any

play12:07

solution in your mind?

play12:09

One thing I can do is I can put this

play12:13

in the i tag.

play12:15

Like we have studied so far.

play12:18

Put it in the i tag.

play12:21

To green, we have to put

play12:22

it in a different tag.

play12:24

Only then we can do it.

play12:26

So, I have put it

play12:27

in the i tag.

play12:30

So, by putting it in the

play12:31

i tag, it will become italic.

play12:33

But then we can

play12:34

make it green here.

play12:36

Style color is equal to green.

play12:39

Close it.

play12:42

So, now it has become green.

play12:44

Zoom in and show.

play12:47

See, it has become green.

play12:50

And if I want,

play12:52

I can make

play12:53

it bold too.

play12:55

So, it has become bold and green.

play12:56

But I don't want it

play12:58

to be bold or italic.

play13:00

I just want to make it green.

play13:02

So, the most common inline

play13:04

element for that is

play13:06

span.

play13:09

So, what does it do?

play13:10

It does nothing.

play13:12

If I remove it, you

play13:14

won't find any difference.

play13:16

See, there is no difference.

play13:18

It is a normal word.

play13:19

It is not doing anything. It is just lying here.

play13:22

So, if we put it

play13:23

like this, it does nothing.

play13:25

It becomes like a word.

play13:27

The advantage of this is that

play13:29

it becomes a little different.

play13:31

It is different

play13:32

from normal text

play13:34

like so that

play13:35

users can view.

play13:38

It is not different in appearance.

play13:40

But the markup of our HTML,

play13:42

markup means the content,

play13:45

is a little different from that.

play13:46

So, now we can give

play13:47

it a different style.

play13:49

So, now if we give it

play13:51

style color is equal to green,

play13:53

then this will be applied here.

play13:55

Now, it is not even bold.

play13:57

See, it is not even bold.

play13:59

And its color has also changed.

play14:02

So, if we want to

play14:04

give a different style

play14:05

to a specific text

play14:07

in a whole line,

play14:09

a small text,

play14:11

if we want to give it a different styling,

play14:13

then we use span tag.

play14:16

So, this is the most

play14:17

commonly used inline element.

play14:19

The second most commonly used block element,

play14:23

what is that?

play14:24

That is div.

play14:26

Its name is div.

play14:28

Its full form is division.

play14:30

Division means it represents a

play14:32

section on the whole page.

play14:34

So, in this case,

play14:36

I will tell

play14:37

you a problem.

play14:39

What is the problem?

play14:41

I will tell you a task.

play14:44

For example, you have to leave this whole section,

play14:46

this line,

play14:48

below this,

play14:50

and then this image,

play14:52

leaving this,

play14:54

this all copyrights reserved,

play14:56

you have to make the

play14:57

whole background hot pink.

play14:59

You can use any color.

play15:01

Just don't use red, blue, etc.

play15:03

Otherwise, it looks too bright in the eyes.

play15:05

You can use pink, green, or even teal.

play15:07

Let's try teal.

play15:09

Teal is a greenish color.

play15:11

So, you can use any color.

play15:13

So, I have to make this much color.

play15:15

This much color.

play15:17

So, according to the current HTML structure,

play15:21

if we go to do that,

play15:23

this is our paragraph tag.

play15:25

This is HR.

play15:27

So, don't touch HR.

play15:29

There is a paragraph below it.

play15:31

So, we will give its background color.

play15:35

We have to style it.

play15:37

Style background color.

play15:39

Give it hot pink.

play15:43

So, this much color is pink.

play15:47

Now, if I copy this,

play15:49

this is the color of p tag.

play15:51

Now, this image is left.

play15:53

So, let's give hot pink here as well.

play15:55

Background color.

play15:57

Here, style is already there.

play15:59

So, we don't have to write style twice.

play16:01

We just have to put a semicolon here

play16:03

and paste the background color.

play16:05

We have to put it in the same style tag,

play16:07

in the same style attribute.

play16:09

So, look at this.

play16:11

We can't see the color of the image

play16:13

because

play16:15

the white of the image

play16:17

is already background.

play16:19

And

play16:21

if we

play16:23

had a transparent image,

play16:25

the background would be visible here.

play16:27

So, for that,

play16:29

I will download a transparent image.

play16:31

Quickly.

play16:33

So, here I have downloaded

play16:35

a transparent version of this image.

play16:37

Now, we will put this in our project.

play16:40

And then we will see

play16:42

how its color is visible in the background.

play16:44

So,

play16:46

here

play16:48

we will make it transparent.

play16:50

If we do a slash here,

play16:52

it will give a suggestion.

play16:54

So, here

play16:56

I have put a transparent image.

play16:58

Now, we can see the background color.

play17:00

Earlier, it was not visible.

play17:02

Earlier, because it was like this.

play17:04

Earlier, because its background

play17:06

was not transparent, it was white.

play17:08

So, it was not visible.

play17:10

Now, we have made it

play17:12

transparent background.

play17:14

So,

play17:16

it is visible through it

play17:18

because its background is transparent.

play17:20

Its background color is visible.

play17:22

From here, we can toggle it.

play17:24

So,

play17:26

that's it.

play17:28

But I want

play17:30

it to be complete.

play17:32

Here, the white space is coming.

play17:34

So, we have to give it

play17:36

10 elements.

play17:38

If I had 10 elements,

play17:40

I would have to give the background color to 10 elements.

play17:42

And if there is a gap in it,

play17:44

it would have been visible.

play17:46

So, the div

play17:48

we use it to wrap

play17:50

many elements.

play17:52

So,

play17:54

this is the p tag and this is the image tag.

play17:56

So, if we put a div on it

play17:58

and the closing tag

play18:00

is placed

play18:02

below the image,

play18:05

it becomes a container type.

play18:07

I will select it

play18:09

and click the tab.

play18:11

So, the div

play18:13

is containing both of them.

play18:15

That means,

play18:17

these two elements are inside the div.

play18:19

The div is the parent

play18:21

of both of them.

play18:23

So, if we set the style background color

play18:25

to

play18:27

pink.

play18:29

So,

play18:31

the whole section is pink.

play18:33

What was there last time?

play18:35

It was something like this.

play18:37

Let's press ctrl z once.

play18:47

Yes.

play18:49

Last time, it was something like this.

play18:51

Because the image is an inline element,

play18:53

the width is only this much.

play18:55

And how much did I want?

play18:57

This much. I wanted this much color.

play18:59

But

play19:02

because the image is an inline element,

play19:04

the background color is only this much.

play19:06

So, if we

play19:08

put it in a block element.

play19:10

Div is a block element.

play19:12

If we inspect here,

play19:14

the div is selected.

play19:16

And look,

play19:18

the display block is shown here as well.

play19:20

Otherwise, we will go to the computer.

play19:22

If we write display here,

play19:24

the display block is written.

play19:26

So, this is the display block.

play19:28

That means, the whole width

play19:30

is from start to end.

play19:32

And we wrap

play19:34

some content in it.

play19:36

This is called division.

play19:38

It divides

play19:40

a section from another section.

play19:42

We use div

play19:44

so that we can group

play19:46

some sections together.

play19:48

And if we want to style it differently,

play19:50

we can do that.

play19:52

So, if I copy this div

play19:54

and paste it

play19:56

or duplicate it,

play19:58

if I use shift-alt-down arrow,

play20:00

the whole div will be duplicated.

play20:02

So, look,

play20:04

it will be duplicated below.

play20:06

If I duplicate it again,

play20:08

it will be three times.

play20:10

So,

play20:12

now we can

play20:14

understand it in three sections.

play20:16

We can think that

play20:18

there are three different sections

play20:20

and we can give different colors to all three.

play20:22

For example, if I give it a teal color.

play20:24

It is a greenish color.

play20:27

So, it is a teal color.

play20:29

And the background color of the image is coming

play20:31

because we gave

play20:33

the background color of the image

play20:35

separately.

play20:37

So, let's remove the background color of the image from here.

play20:39

And if we remove it from here,

play20:41

still

play20:43

where is it?

play20:47

Here.

play20:49

From here.

play20:51

From the top one.

play20:53

So,

play20:55

I have removed the background color of the image from here.

play20:57

But because

play20:59

the parent of this image is a div.

play21:01

The color is given on it.

play21:03

So, it is visible.

play21:05

Because it is a transparent image.

play21:07

And then the second color of this is done.

play21:09

Then let's give some color to this too.

play21:13

If we press ctrl-space,

play21:15

then automatically all the colors in CSS

play21:17

are suggested.

play21:19

Which one should we try?

play21:25

This dark.

play21:27

Dark sea green.

play21:29

Let's do this one.

play21:31

Here also the background color of the image

play21:33

is given separately.

play21:35

Let's remove this too.

play21:40

So, we have three sections.

play21:42

We have given

play21:44

different styles to all three.

play21:46

Although it looks very bad.

play21:48

Normally,

play21:50

when we do this,

play21:52

we don't give any color.

play21:54

Let's categorize for other purposes.

play21:56

So that our code

play21:58

is in a category.

play22:00

This is our top header section.

play22:02

Then there is an article section below it.

play22:04

That's why we group it

play22:06

separately.

play22:08

So, these are our three sections.

play22:10

Mainly.

play22:12

There is some content in it.

play22:14

So, these are three big sections.

play22:16

So, what does division do?

play22:18

It divides our whole page

play22:20

into different sections.

play22:24

So, for a minute,

play22:26

if we open any famous website

play22:28

like amazon.com

play22:32

and right click here

play22:34

and inspect.

play22:36

So, we can see

play22:38

let's make it smaller.

play22:40

So, you can see

play22:42

that here

play22:46

there are so many divs.

play22:48

Div, div, div.

play22:50

So many divs have been used.

play22:53

So,

play22:55

div tag is used in every website.

play22:57

Div is the most commonly used tag.

play22:59

We will learn CSS

play23:01

and make a layout.

play23:03

So, we will need to use div a lot.

play23:05

And sometimes

play23:07

we will also use span tag.

play23:09

When we have to

play23:11

give a different color

play23:13

to a small text in a small sentence.

play23:15

In that case,

play23:17

we will use span tag.

play23:19

So, in this video, we saw

play23:21

what are inline and block elements.

play23:23

And we saw

play23:25

div and span tags

play23:27

which was a new tag

play23:29

for us.

play23:31

Span is an inline element

play23:33

and div is a block element.

play23:35

When we learn CSS,

play23:37

we will understand in more detail

play23:39

and depth

play23:41

how an inline element

play23:43

can become a block element.

play23:45

so we will learn this, when we will reach CSS,

play23:51

In next video, we will learn what is semantic tags in HTML?

play23:54

what is its use? and what are the benefits for using that?

play23:57

so that's all for this video, see you in the next one till then bye bye!

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

5.0 / 5 (0 votes)

Related Tags
HTML BasicsInline ElementsBlock ElementsCSS StylingWeb DevelopmentFront-EndAnchor TagsList FormattingText FormattingDiv TagSpan Tag