The differences between DIV and SPAN tags
The DIV and SPAN tags are very similar but they have a different meaning. While the DIV tag is used to group elements together as a whole grouping the span is used as a way to just mark without any meaning some content. In other words you can never put a DIV inside of a SPAN tag. Click play to learn more.
Video Transcript
00:00All right, so I wanted to talk briefly and quickly about we met the div and we talked about the span
00:06but we didn't really see it. We said the div really holds inside a full section of things,
00:12like a whole block of copy. By the way, it automatically also breaks the line. It's
00:18very similar to the way paragraphs work. It's a block level type of element, which you could
00:23control via CSS as well, but we're not going to go dig that deep into the world of CSS.
00:28But I did want you to get familiar with the span tag. The span tag enables you to create
00:34styling in a very small place, such as inside of a paragraph. So let's say I wanted my lish to be in
00:40English. So to do that, I would wrap my lish with a span, and that span will not change anything
00:50by default. By the way, you're not allowed to put a div inside of a span. You're allowed to
00:57put a div inside of a div, but you're not allowed to put a div into a span because a div is a
01:04block element element versus a span. It's only line. Exactly. So if we create a span and I go
01:09right into the browser to that page and click on refresh, you'll see that you'll see nothing.
01:13Nothing has changed because I didn't say to it anything. Lish didn't do anything.
01:17Contrary to that, if I went here and I put here a div element instead of a span,
01:21look what will happen. All right, so we set here a div, and if I click on refresh,
01:27this time around, you'll see that it's going to break my lish into a separate standalone element,
01:33just as you would if we put a paragraph, right? So obviously we wouldn't want that. So we're going
01:37to work with that span. And what I'm going to do, I'm going to do an inline style. As we said,
01:41that's not going to let me do one more style. There's three, there's three basic ways of
01:46writing CSS. We saw one way of approaching an element directly, which would then change every
01:52single h1 to do whatever's inside of here. We saw how to do it with p making every single p
01:57do what's inside of it. We also saw how to approach something specifically by its ID,
02:03meaning that only that specific element could have it. On the contour error, we could have
02:07also saying that's called a name or a class. By setting a class name to us to an element,
02:14we could put a few classes inside, but we could set a class such as let's say the white class.
02:19Oh, that sounds horrible. That sounds racist. Let's change the different name. Let's call it
02:23the lish class. All right, so we have the lish class. So in our lish class, now that we have
02:29a lish class, the way we could approach it is we could set a lish dot lish. Now anything that has
02:36a class called lish will have these attributes that are inside of here. So for example,
02:40background white. All right, so lish, although it doesn't make any sense, but roll with me here.
02:49So lish is white. And if I go now into my browser and click on refresh, we'll see that our lish
02:56element should now do nothing. Let's see why and why, why, why. So I'm going to save that and make
03:01sure that I'm updating my CSS to go to the new file. I always forget that. So four,
03:07and this is going to be span. And again, we're going to go into our browser, click on refresh.
03:14And we should see that now we have a background of a white background for our lish. Obviously not
03:20that useful. But we can also now use the same span class any place that we want. So for example,
03:25maybe you want to put that lish class onto our up, we could use literally the same exact code,
03:32and it will automatically put that functionality in it as well. It's not unique to one specific
03:37element, but we could reuse it as many times as we need to. Alright, so for example, we could
03:43create a highlight class or something of that nature. By the way, you could put much more than
03:47only one class, you could put as many classes as you want separated with a space. Now there's
03:51a lot more ways and things you could do with CSS. Unfortunately, this isn't a CSS course.
03:56This is as advanced as we're going to get in CSS. And now it's up to you to continue exploring
04:01into it and finding more things in CSS. We covered quite a lot of CSS basics, and you
04:07should have enough here to start playing with CSS for a few good weeks. We are in the process
04:12of developing now a course on CSS. So by the time you're watching this, it's probably already
04:17ready. And if not, just make sure you're following our newsletter because we update you on new
04:21releases deals and so on and so forth. And what's going on with us in our newsletter.
04:27I think that's about it for CSS. We're done with CSS.
