Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Controlling line breaks

From: Up and Running with HTML

Video: Controlling line breaks

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.

Controlling line breaks

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.

Show transcript

This video is part of

Image for Up and Running with HTML
Up and Running with HTML

49 video lessons · 26997 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 2m 12s
    1. Welcome
      55s
    2. Using the exercise files
      1m 17s
  2. 29m 30s
    1. Learning HTML
      2m 47s
    2. Choosing a code editor
      5m 2s
    3. Exploring basic HTML syntax
      8m 18s
    4. Do I need to learn HTML5?
      5m 6s
    5. Exploring HTML references
      8m 17s
  3. 35m 40s
    1. Exploring an HTML document
      5m 19s
    2. Working with doctype declarations
      4m 3s
    3. Examining the document head
      8m 20s
    4. Looking at the document body
      3m 21s
    5. Adding document structure
      8m 52s
    6. Lab: Coding a basic page
      3m 9s
    7. Solution: Coding a basic page
      2m 36s
  4. 1h 23m
    1. How does HTML format text?
      5m 51s
    2. Adding headings
      7m 24s
    3. Formatting paragraphs
      4m 54s
    4. Controlling line breaks
      3m 50s
    5. Creating lists
      10m 37s
    6. Emphasizing text
      6m 42s
    7. Displaying special characters
      5m 8s
    8. Controlling whitespace
      4m 35s
    9. Inserting images
      9m 20s
    10. Lab: Controlling page content
      13m 57s
    11. Solution: Controlling page content
      10m 55s
  5. 31m 54s
    1. Linking to pages within your site
      6m 45s
    2. Linking to external pages
      3m 2s
    3. Linking to downloadable resources
      2m 25s
    4. Linking to page regions
      8m 0s
    5. Lab: Creating Links
      5m 57s
    6. Solution: Creating Links
      5m 45s
  6. 40m 27s
    1. Examining basic table structure
      5m 10s
    2. Adding content to tables
      6m 20s
    3. Setting table attributes
      7m 42s
    4. Adding table captions
      4m 3s
    5. Defining table headers
      2m 13s
    6. Making table data accessible
      5m 46s
    7. Lab: Building tables
      4m 13s
    8. Solution: Building tables
      5m 0s
  7. 43m 23s
    1. Understanding the relationship between HTML and CSS
      4m 58s
    2. Creating inline styles
      4m 53s
    3. Exploring the style element
      5m 13s
    4. Basic font styling
      9m 24s
    5. Changing color
      4m 55s
    6. Taking styles further
      5m 24s
    7. Lab: Controlling basic styles
      5m 10s
    8. Solution: Controlling basic styles
      3m 26s
  8. 5m 44s
    1. Next steps
      2m 56s
    2. Additional resources
      2m 48s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Up and Running with HTML.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.