Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
CSS enables you to control the look and layout of a web page much more precisely than you could with HTML alone, but it can be time-consuming to learn. In this workshop, expert developer Candyce Mairs makes styling a quick and easy process, walking you through the process of adding content to a web page and using CSS to position that content. Candyce explains CSS positioning concepts like the CSS box model, floats, and clears and demonstrates how HTML and CSS work together to create the look of your web page. By speaking the same language as the browser, you can learn to work with the browser to place content accurately and easily.
When working in CSS Positioning, we need HTML and CSS to work together. So, the first step is the HTML side, and that's what I want to take a look at now. And what we're going to do is create a new HTML page. So I'll just got to File > New HTML Page, and within this page we have all the basic HTML tags. What I want to do is add some additional HTML tags to the page. Let me go ahead and save this first, and when I go to Save it, because I have a project defined it saves it to that folder automatically. So, I'm going to name this, html-div-tags, and I'm going to use dashes between words as my standard throughout the course. As you can see, that's how your pages are set up. So, any time I save multiple words, there will be a dash between them. Now what I want to do is use this new page to demonstrate the DIV Tag, because it's an important tag when we're working in CSS Positioning. Within the CoffeeCup editor that I'm using as my HTML editor. There is a tab called Code, and when I click on that tab and go to this last icon up at the top for XHTML, that's the DOCTYPE I'm using. It gives me a listing of all of the HTML tags coded as XHTML. And what this does is allow me to drag those tags out onto the page, so you don't have to watch me type them all.
So, what I'm going to do is use the DIV Tag. That's one of the most important tags in CSS Positioning. So, I'm going to drag some of those tags out and I'll drag three of them. So, if you're using a different type of editor, what we want are three separate DIV Tags. Now the first one is going to say, this is div 1. The second one is going to say, this is div 2 and div 3. So, what I'm going is creating multiple DIV Tags on the page. So, do this in whatever manner you like within your specific editor. I'll save the page, and now that I've saved the page, if we preview this, let's take a look at what happens.
I'll go over to my local preview, and I'm going to use Firefox for this one, and you can see, hm. Each DIV is shown on its own separate line in the browser. How can that be? Well, that's what a DIV Tag does, it places content into its own space. Because div 1 is the first item listed on the page that becomes the first line, within the browser itself. So, we know that what a DIV Tag does is place content in its own space, or on it's own separate line.
What happens if I duplicate this? I'll just copy and paste it, so we have a few more copies. I don't worry about the numbers here. I just want to show you what happens if I use a SPAN Tag instead. So, I'm going to take a couple of these in the middle. And I'm going to convert them to a SPAN Tag instead of a DIV. You'll see SPAN Tags used quite often with CSS. But they're used in a particular way and that's because of the properties built into the tag. So, if I go over to Firefox again, notice my SPAN Tags, they're both on the same line, my DIV Tags are not.
So, what does a DIV Tag do? What a DIV Tag does automatically within HTML is place content in its own line. What a SPAN Tag does in HTML is absolutely nothing. It's the only HTML tag that has no built in properties. So, that's why we tend to use a DIV Tag when we're working in CSS Positioning. We can surround content, and what this does is segregate that content out into its own space.
So, that is the difference between a SPAN Tag and a DIV tag. And the DIV Tag is where we start all of our HTML pieces. Everything related to CSS Positioning is usually done using the DIV Tag. So, that is what an HTML DIV Tag does.
There are currently no FAQs about Exploring CSS Positioning.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.