Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
This course is designed to quickly lead you through the steps of building an HTML website, from creating a new page to building links and tables. Author James Williamson simplifies the coding process, with straightforward steps you can recreate on your own. The course explains the basic structure of an HTML document, shows how to add text and images, and introduces font styling with CSS. James also offers a bonus design challenge at the end of each chapter, where he asks you to think of a solution before offering his own.
There will be times when you need to force a hard return but don't want to start a new paragraph. In those instances, you'll want to use a line break. I'm going to go down into my code here, the very last line where we have the address, lynda.com 6410 Via Real Carpinteria, California, 93103. All of that is in a single paragraph, and that is as it should be. This is an address. But what I would like to do is I would like to have, in terms of the visual display, have each one of the lines of the address show up obviously on separate lines.
So, in order to do that, we're going to use what's known as a line break character. What I'm going to do is I'm going to come into this last paragraph and right after the text lynda.com I'm going to enter in a line break. So this is a line break. It's just the br tag. And it doesn't really matter where you place this. You'll notice, for example, that right now I've placed it after the words lynda.com and I've left a little bit of whitespace there for the 6410. Well, if I save this and preview this in my browser--and I'm just going to go ahead and refresh this page--you can see that it ignores that little whitespace over there.
So basically, what the Line break does is it's going to cause a hard return down to your next character that it finds. Now, you can use other things if you actually wanted to control a little bit of whitespace there, but for the most part, it's just going to cause a hard return down to the next character. In order to get the rest of this, all I have to do is go to the 6410 Via Real and we'll enter in another line break there. Now a lot of people like to go ahead and add those hard returns into their code as well, just to make this a little bit easier, for you to read, but it does not matter.
You'll notice, having that line break tag in line within the element didn't harm at all and it still displayed exactly the same way. So really if you format your code like this, that's just really a personal choice for you, in terms of how you want to read your code. So I save this, come back over, preview the page, and you can see that now our address is all in separate lines. But what's nice about this is it's still all within the same paragraph. So it's still grouped together. It's still part of that same related content. If we replace those lines in separate paragraphs, they really would lose the relation to each other and that would be improper syntax.
So using that line break is really nice. That's pretty much it for the line break tag. There's not a lot that goes on with it. Occasionally, if you are looking at somebody else's code, you might see this look a little bit differently. Any type of tag that you have that is a single tag with no closing tag-- so a line break tag has no closing tag applied to it. It never contains any content. It's just the opening tag. There is no end tag. Sometimes you are going to see that syntax represented like this, with a forward slash at the very end of it. So you'll see a space and then a forward slash, and this is what's known as a self-closing tag.
When HTML 4.0 moved over to XHTML 1.0, one of the rules in XML, in terms of syntax, is that all tags have to have an opening and a closing tag. They were trying to transition authors into using that type of syntax, and quite frankly this just looks silly. If you do br and then, a closing br, that just looks silly. So they came up with a compromise, which was essentially having a self-closing tag. Now, that's not actually valid HTML 5.0 or 4.0 syntax, but almost all of the user agents out there understand that, and they'll render it just fine.
A lot of people that were in a habit of writing XHTM--and I certainly was one of them--got into the habit of doing that, and it actually took me a while to go back to not doing self-closing tags any more. So, you'll quite frequently see that done with image tags and meta tags and line breaks. Another thing to keep in mind when you are using line breaks: they don't actually create a new section of content. You're just gong use them whenever you need to force to a harder return without creating a new paragraph.
There are currently no FAQs about Up and Running with HTML.
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.