We launched a new IT training category! Check out the 140+ courses now.

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

How does HTML format text?

From: Up and Running with HTML

Video: How does HTML format text?

As I mentioned earlier, HTML is a markup language. This means that HTML uses tags to format the content of the page. Once you're comfortable with the syntax behind formatting content, then it simply becomes a matter of learning which tags are available to you for formatting and the options you have when using them. To illustrate that concept a little bit more clearly, I'm going to be using the format.htm file you see here. So you can see here, within the body of our page, we just have a single line of text that says, "What am I?" Well, currently that line is not being formatted at all.

How does HTML format text?

As I mentioned earlier, HTML is a markup language. This means that HTML uses tags to format the content of the page. Once you're comfortable with the syntax behind formatting content, then it simply becomes a matter of learning which tags are available to you for formatting and the options you have when using them. To illustrate that concept a little bit more clearly, I'm going to be using the format.htm file you see here. So you can see here, within the body of our page, we just have a single line of text that says, "What am I?" Well, currently that line is not being formatted at all.

It has no tag around it to identify it, other than belonging to the body of the page. Now, if I were to preview this in the browser, you can say that it does display on the page as just a single line of text, and it sort of has the default font size and formatting that you would expect to find in just regular paragraph text. So the browser is basically just giving you the default formatting for text within the browser. However, if I go back into the code, I can change the formatting of this text by simply applying another tag around it. So that's exactly what we are going to do.

So right around "What am I?" I am just going to ahead and create a new tag. I am going use a pre tag. Now, I don't think we've seen this one so far in the title. We will be seeing this a little bit later on as well. So again, I am just going to do an opening and closing tag that wraps around the text "What am I?" I am going to go ahead and save this. If I go back into my browser and refresh my page, I can see that the text does indeed change formatting. Just because you're changing formatting doesn't mean that everything that we do in HTML is presentational; it's actually the other way around.

HTML describes the structure of the document, so essentially pre, which stands for preformatted, you're telling the browser this is preformatted text. Every single browser out there has what we call a default style sheet. Now what that means is is basically there's a little style sheet that says, okay, what type of element is that? This is how I am going to format and display that on the page. Now, using your own styles, you can override those, and we will do that a little bit later on in this title. But for the most part, the formatting that we are seeing on the page is actually representative of what type of element it is.

You can see preformatted text, for example, is typically displayed in a monospaced font and the reason for that is because that pre tag is used a lot around code snippets or code segments or things like that, so monospace fonts are typically really good for that. Of course, you can use CSS to style it any way that you want. So if I go back in and I change the tag that's around it, I am going dramatically change the meaning of the text. So right now it's preformatted text, but if I surround this with, say, an h4, which is a heading4 and save that and test it, I can see it again the text changes.

It's bigger, it's bolder. It's now a heading. I notice that it's not that large, because it's a heading4. If on the other hand I change that to a h1, which is a top-level heading, save that, and test it, you can see the text gets a lot larger. Again, the browser is simply giving you a visual representation of what type of element that is. We're not actually passing any formatting instructions whatsoever. So for the most part, when you apply a tag around text to create an element, you are essentially telling the browser, or whatever user agent is parsing that page, what type of semantic structural element it is.

Now, it's not always so cut and dry, in terms of being structural versus presentational. Let me show you what I mean. Let's go back into our code, back into our heading1. What about the text "am?" What if I wanted to change that and italicize that, or make it appear italicized within the heading? It's very easy for me to do by just using the i tag, or the italics tag. So I am going to go ahead and wrap the word "am" in the italics tag, and of course it's okay to nest one tag inside of another. So if I save this, go back in, and preview my page, I can see that now the word am is indeed italicized.

The italics tags, along with tags like the bold tags, are a small section of tags within HTML that are entirely presentational. And what that means is they don't actually mean anything. We didn't change the meaning of this text at all. We just informed the browser to go ahead and display that text as being italicized. There is a big movement among web designers and developers over, say, the last five to ten years, to be honest with you, to separate presentation from structure. And what that means is is the goal is to just have your code represent the structure of the text--what type of element this is--and then you allow CSS, which is a presentational language, to control how it looks.

But there are still some more remnants of presentational markup in HTML and the italics tag is one of them. When would you use it? Well, for a case just like this, when I wanted to italicize that text but not necessarily affect its meaning. Again, as I mentioned, that's not always cut and dry, because there are other tags out there that seemingly do the same thing. Let's say for example I use the em tag, em, instead of the italics tag. If I saved this and previewed it, nothing changes. It's still italicized. However, behind the scenes there is actually a much bigger change.

The em tag stands for emphasis. So now the word "am" is being emphasized, whereas before it was merely being italicized. And we are going to explain this a little bit later on in this chapter as we talk about emphasizing text and what the difference is between some of these presentational versus structural elements are. That's why it's so important to understand what these tags are and what they're doing and what they're saying about the underlying text. As a markup language, all you really need to do to properly format content in HTML is to simply wrap it in the appropriate tag.

Of course, this means that part of the joy of learning HTML is learning all of the different tags and when they are appropriate.

Show transcript

This video is part of

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

49 video lessons · 27554 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

Course retiring soon

Up and Running with HTML will be retired from the lynda.com library on October 31, 2014. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion. For updated training, check out HTML Essential Training in the lynda.com Online Training Library.


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 preferences from 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.