Paragraph level formatting
Throughout this chapter we explore the ways text can be manipulated in HTML leveraging CSS rules. In this last lesson of the chapter, we will learn how to define paragraph rules to HTML elements. By the end of this lesson, you will know how to define word spacing, define line height, letter spacing and even how to keep white spaces in HTML documents.
Video Transcript
00:00As we travel through manipulation of copy, we went through the font itself.
00:05We went through the decorations that surround the font,
00:08and we're moving now a layer bigger into the paragraph level,
00:11and the relationship between each character to the character next to it,
00:15between each word to the word next to it,
00:17and between each line and the line following it.
00:20By then, this lecture, you'll have all the tools you need to control
00:24the flow and aesthetics of how paragraphs look like.
00:28Let's jump right into it.
00:30It's time for us to take a deeper look at how do we control
00:33actually the way text is rendered inside of a paragraph.
00:37To do that, I'm going to go ahead into my multi-class,
00:43and go ahead and just unjustify it.
00:46I'm going to go here and just make sure that my text alignment is more natural.
00:52I'm going to set it to go to the left so we could start looking into
00:55the different things that we could do to control our copy.
00:58You see that now the text is not justified,
01:01and we're ready to start looking at different things
01:03that we could do to control our text.
01:05The first of them is the word spacing.
01:07Word spacing enables me to put a value of how much space is there
01:11actually between words.
01:13I could put there any of the numbering systems that we looked at before,
01:16but for example, I could set the length of one character.
01:21If I do that, then my copy would basically have there a space
01:25of one of that size of our character.
01:29Really, I could put any value.
01:32I could go ahead and say, hey, I want this to be 10 pixels,
01:35or I want it to be 10 points.
01:37Pixels would probably be not a good measurement,
01:39mainly because pixels are rendered differently on different screens.
01:44I might want to go for something that is much more direct,
01:47such as maybe I want to set it to be one inch.
01:50Obviously, that would probably be a very, very big spacing
01:55that would not make sense.
01:57Really, one of the most common measurements
02:00when you're talking about fonts is points.
02:02I love using relative paths.
02:04Even if the one EM was too much, I would just go to zero denim.
02:09The reason why I love using the EM is that relativity,
02:13so I could then control that as my copy grows,
02:16I would have that relatively grow.
02:18If in a different browser, the font is a different size,
02:20then the spacing would be a different size as well.
02:22That's personally my preference,
02:24and I could then go ahead there
02:26and just go and find the right amount of spacing
02:28that really works best for me using those relative paths.
02:32That is how you control word spacing.
02:35It's literally just a number.
02:37It has a default value, which is normal.
02:40It's an inherited property,
02:42so all the things inside of it would get inherited as well.
02:47I could override it in an inheritance and say,
02:50hey, I want you to be normal.
02:52Besides word spacing, there's also letter spacing
02:55that works basically the exact same way
02:58where I could define how much space is there between letters.
03:02I'm going to go ahead and put there maybe 0.5 EM.
03:07I'll go ahead and save that,
03:09and we'll see that there is a nice spacing now
03:11between the characters, a lot more space between each word.
03:15Now I could make that spacing again
03:17something a bit relative like I've done now
03:19or put a hard-coded value.
03:21This works for me, at least for this sample.
03:24We've seen already line height,
03:25but I want us just to see it one more time
03:27in the reference to the paragraph that we're in.
03:30The line height enables us to change
03:32how much spacing is between two lines.
03:34For example, if I wanted to be a two,
03:36basically two lines spacing,
03:40then I would just set it to two EM.
03:42If I would do that, I would have a spacing
03:44of an extra line in between.
03:46Or if I wanted to, just like in a word paragraph,
03:48I could go ahead and say,
03:50okay, I want it to be one and a half the spacing.
03:52Again, it's all about controlling relatively
03:55and finding that spacing that works best for you.
03:57Obviously, this is a lot more legible
04:00than the copy right here
04:01because this is a lot more condensed.
04:03It might be nice to read if it's an article,
04:06but if you're just trying to get people
04:08to read a short blurb,
04:09this would probably be a lot more legible.
04:11Maybe it needs a little bit more work
04:13to make it a little bit better,
04:14but in general, we're in the right direction.
04:17All right, so with that said,
04:18let's move on to the next item,
04:20and the next item that I want to talk about
04:22is literally how do lines actually break?
04:26Now, by default, in a paragraph,
04:28it knows it's a box,
04:29and it just basically word wraps automatically.
04:32But what if you didn't want items
04:34to word wrap automatically,
04:36and the way you do that,
04:37you control that using the command white space.
04:41Now, white space.
04:44White space, by default,
04:46its value is normal,
04:47but I could set it to be pre,
04:49which pre basically says,
04:50don't do anything.
04:51Put it the way it is.
04:53By putting it the way it is,
04:55we'll see that now our copy
04:56would just go all in one long,
04:58endless line that will go on almost forever.
05:01I could then go ahead there
05:03and manually put break lines
05:04wherever I want to.
05:05So, for example,
05:06I might want to break a line right here,
05:08and I might want to break a line right here,
05:10and I might want to break a line also right here.
05:13Okay, so we've created a few break lines,
05:15and I'm going to save that,
05:16go back into my application,
05:17and click on refresh,
05:18and you'll see that now
05:19those break lines are being respected.
05:21Notice another thing,
05:23that we have all this extra space going on here,
05:25and if you look into your application,
05:27you'll note that automatically,
05:29we had all these indentations
05:30that before were ignored,
05:31but now they're not ignored,
05:33so all the space is also counted in.
05:35So not only did we break a line,
05:37also all this white space has been added in.
05:40But what if we wanted to just be able
05:42to control break lines,
05:43but we still wanted our copy
05:46to Word Wrap in some sort.
05:50So right now our copy is not wrapping at all.
05:53There is no wrapping at all going on,
05:55but the line breaks are being respected.
05:57How about let's go for this.
05:59What if we wanted to ignore the line breaks,
06:01but still not to have any Word Wrap?
06:04To do that,
06:05we could literally just change the attribute here
06:08from pre to be no wrap,
06:10and no wrap as the name implies
06:12will basically it still ignores the break lines,
06:15but it won't Word Wrap our copy
06:17even if we put break lines inside of the text,
06:20which by default,
06:21the default ignores breaks lines
06:23and ignores extra spaces
06:25that basically cleans them out.
06:27Another option we have is to set it to wrap,
06:30but also to respect our white space
06:33and our break lines,
06:34and if we set it to pre-wrap,
06:36then our copy will also respect the extra lines,
06:39the extra space that we've put inside of our characters
06:42and also respect the break lines,
06:44but yet it will continue to Word Wrap
06:46in scenarios where we didn't.
06:48Last but not least is line wrap
06:51and or pre-line,
06:53and pre-line does not,
06:55it Word Wraps and respects breaks,
06:57but it does not respect empty lines of space.
07:01So it would basically ignore the extra spaces
07:04that we have there,
07:05but it would break the line in places
07:07where we ask it to break a line.
07:09So the characters are breaking,
07:10the spacing is not messed up
07:12because of all that white space.
07:14So there you go,
07:15those are all the different options
07:16of setting and configuring white space,
07:18and now you know also the differences between them,
07:21and throughout this lecture,
07:22we've seen basically all the different ways
07:24we can manipulate paragraphs
07:26to try to get them to look the way
07:28that we want them to do
07:29for the spacing in the characters,
07:31the spacing of between words,
07:33to the spacing of lines,
07:35all the way through the rendering itself
07:38of the actual copy itself.
07:40So that's it, that covers this lecture,
07:42and we're still talking about text
07:44and paragraphs and how they work,
07:46and we'll see you in the next lecture
07:47where we continue exploring this topic.
