Aligning and text direction
The first thing we need to do when working with text is define their language format layout and their overall direction and alignment. By the end of this lesson, you will know how to define the direction of text and its alignment.
Video Transcript
00:00It's time for us to focus on what this chapter is all about text and we're gonna start off by aligning our text
00:06We're gonna learn how to center it left to the right to the center both vertically and horizontally
00:12By the end of this lecture, you will know how to control the location of your element within its box bounding
00:20All right. So let's jump right into it
00:22Let's talk about text alignment
00:25So let's just jump right into it. Really the beginning is incredibly simple
00:29I'm just gonna go to that h1 that I have in the
00:32Starter of my paragraph and I'm gonna go ahead there
00:36I just want to set it a background color so we could see it more easily
00:39I'll just give it an RGBA for this simplicity set it to white and give it an alpha channel of
00:4620%
00:47All right
00:48So now that I've set a background I'm ready to give it a text alignment
00:51And I'm gonna go ahead and align my text to be in the center of the screen very simple
00:56Now there's a couple of there's basically four options that I have I have my center point
01:01So you could see that my copy is right there splash in the center
01:05I could set my copy also to be to the left to the right, which is quite intuitive or to justify
01:11So I'm not gonna dig too much deeper into this besides going to one of our paragraphs and setting it to be justified
01:18I'm just gonna make sure that you have access to the different options right here right underneath that element
01:25But I'm gonna go into my paragraph and I'm gonna go ahead and set it to justify to the left
01:30By setting my text the line and then setting it to be justified
01:36And that's it. That's what I had to do to set it to be justified
01:39If I go ahead and I click and refresh we'll see that our content is gonna be a lot more clean and more beautifully presented
01:46Beautiful with that said we're done with that topic and we're ready to move to another topic
01:51Which is how do we align copy within it?
01:54Now to showcase the sample behind the scenes while you were away
01:57I went ahead and added a little bit more copy into our paragraph and wrapped it around a span
02:03Well, not a paragraph around our h1
02:05I just added is good and set it inside of a span. I've done that so I could actually go ahead and
02:12Continue on and define it now, by the way, if you're asking yourself
02:17What was the default and if I ask you what is actually the default in the alignment right left right center?
02:23Justify well that really just depends on if we're in a LTR or RTL language
02:29So if you went ahead and define the direction to be a different direction your default
02:34Would be based on your language. So right to left would have one alignment while left to right would have another so it's really based on
02:41That are really intuitively. So
02:44Alright with that said, let's move on to the next topic and that next topic is really going into
02:50Controlling the positioning and alignment of content within a paragraph or within any area really and in this case
02:57What I want to do is I want to go to the copy that's going to be that's in the span inside of our h1
03:03So I'm going to go ahead to find our h1 and right underneath it. I'm going to go ahead and create another h1
03:09Span this time around so I could control any span that is inside of h1s
03:14and I'm going to go ahead and talk about the virtual alignment and
03:19I'm going to go and not I'm not going to go through every single one of them
03:22But I'm going to go ahead and add here just so you have access to all the different rules and you could play around with
03:28Them and I'm just going to go ahead here
03:30I'm going to make sure that I have it here. Let me just copy it
03:35There's quite a lot of it and let me just grab it put it right here
03:40And it is incredibly long. So let me just also break a line
03:45Word wrap it so we could see it more easily. Let me just click on save
03:50I must have your some sort of an error because I don't see why oh because I didn't finish defining
03:55Okay, obviously. All right, so let me define something now. I'm gonna go ahead and before even I do this
04:00I'm gonna go ahead here and add one more thing and that is I really need to be able to and I'm just gonna
04:05Delete that for a second. I really need my text itself to be smaller
04:09so I'm gonna go to my text and I'm gonna define a size for my text and
04:14The size of my text that I'm gonna do is I'm just gonna put here a relative size
04:17And I'm just gonna set it to be half whatever that certain item is really breaking it down to be much smaller
04:24Half in size or I could go even a little bit more extreme to make it 30% of the size of the actual
04:31h1 paragraph that we have now that I've
04:35Defined it to be relatively smaller than the bounding container that it is within
04:40The top it's time for me to start playing around with that vertical position now
04:44Let me start with that vertical line and I'm gonna start with the baseline
04:47Which is gonna be relatively intuitive and if I go ahead here and click on refresh
04:51We'll see first of all our copy is much smaller and literally as if you have an invisible line here
04:55My copy is just continuing with that baseline. Now. There's quite a lot of options if I set it to be for example top
05:04And I'm just gonna let you just go through them
05:06I'm just gonna show you a few of the important ones if I set it to be top
05:09It's gonna go to the top of my bounding box, which is that is our bounding box
05:13So it literally is going all the way to the top
05:16Contrary to that if I set it to be and by the way in my case, it should have gone to because
05:22because a
05:24Span does not have a bounding bus. It's part of whatever it's really in it goes to the parents bounding box in this case of
05:32The whole h1 now if I wanted it to bound based on the actual line that I'm in I could go ahead and say hey
05:39Define yourself based on the text top and not the actual top of the box itself by doing so
05:44It's gonna align itself to be as if there's an invisible line defining the top of this element
05:51That's a so that same logic applies to bottom and text bottom and we have a middle which would enable us to be in
05:58the middle of the box itself
06:01And
06:03Another option that we would have is to go ahead into a percentage tile you setting it for example to 0% which the 0% would set
06:11It up exactly in the position of the bottom line
06:16Which is the default really and then I could go ahead there and say hey by the way
06:19I actually want you to be a hundred percent above that
06:23then I would they then I would be a hundred percent up and I a hundred percent up of that that
06:30Sides of that actual element not a hundred percent of the buckets up box itself
06:34Or I could define it minus 100 if I really wanted it to be completely underneath the copy and
06:39I could as well if I wanted to use actually pixels so I could use the actual direct measurement say okay
06:46I wanted it to be 10 pixels above that
06:49Baseline of the beginning of our paragraph, so it would push it up a little bit further in 10 pixels
06:55So you have a lot of control over. How do you want to position your copy?
06:59relative to our
07:02Positioning of the box that we're inside so play around with all those
07:06Items and get familiar with them. You don't have to memorize them again
07:09But it obviously will help you to create content that is aligned completely so for example if I really wanted my
07:15Now I really wanted to flesh well
07:17We already went through all the samples is no point in really hashing it through further because I'm sure this will be relatively simple
07:23But if you have any question, please feel free to drop it on the line below in the commenting section
07:27And we're ready to move on to another topic on controlling text and paragraphs
