How to add a css style to the first line of a p tag on a website (
Hey there, this video, we're going to look at adding a CSS class to make things bold for the first line only, it doesn't matter what's in the line. Okay, Everything will become bold. You can do it for the first letter or the first line. It's a funny little bit of CSS. Let's work out how to do it now, in V. S. Code. Alright, so looking at my mock up, that's what I wanna do. Okay, I want to make the first line bold and then the second or all the rest of the lines, Not bold. Cool. So we are going to look at our weird little CSS class. So Visual studio code, the first thing we need to do is add a bit of text. Okay, so we're going to add it to all of the l a little boxes at the moment. We've got nothing so to clean everything up, let's get rid of the background color. Okay, I'm going to use it for in here, not in the background. So I'm gonna go to V. S. Code. My container has a color that I want to steal and add back to the columns. Okay? Because before I wanted to get rid of it now I want ...
to edit that's kind of picking out the bottom there, but it's all right, I'm going to add text and make it really big. You could um what we're gonna do actually, let's just do it then. And so the column here is going to have some text inside of it the moment it has an image after the image. Okay? So because my image tag kind of finishes there, I'm going to put it in a P tag. Okay. And I'll put in some Lauren Ipsum one about 8 words. Okay. And I want at the beginning here, um, putting the word branding. Cool. So that's what I want to start. I want to target this. Okay, and let's have a look at it in here. You can see how, what I've done here. I've made the column. Okay. It has a it doesn't have a height so it expands for the stuff to fit it in. There's an image in it because they can't fit together, they squish out and the column gets a little bit bigger. I could make a second div underneath it. Okay. Call and then I don't know cole name and style that green in the background, but This one is a bit simpler. Okay, I want to go and style it or looking really good. But let's just put in the bowl first because that's what you came for. And the way to attack it is we're gonna put it in our global styles. It's not crazy difference in tax except we use two colons. Okay. To join them up. Okay. And I want to style the first first line, you can do the first letter, the line. I really want the first word, but that's not an option. So I'm going to do first line. Okay. And I'm gonna make the front weight. Okay, font. Wait, I'm going to make it bold Only because I don't have I should put in like 700 is a very normal bold size but I haven't picked a font yet which is using times roman. You can put any style you like as long as it's text styling and it's going to kind of work and have a look works perfect. Okay. The reason I say kinder is that I'm kind of attacking all p tags first lines and in our mock up here we're going to have more than one bit of text. Okay, so there's gonna be text here here here. I'm bound to have another page with like I only actually have one P tag on this website. But if I go to the contact us page and I build that out, I'm going to use lots of p tags. I don't want them all to be bold. So we're going to be very specific. Okay, so we're going to say only the first line of p tags that are inside columns. Okay, so the space between those two to Collins to join those two up. That's how to do that one. Let's go through install a font. We will get it looking like this. Where are we going to cover anything new? No, we're just going to put some padding in, make it wide to make it the right font. You can skip along if that all sounds easy to you but if it doesn't carry on, we'll do it together. First up a font. So I'm going to go to google fonts at google dot com slash fonts. The fund that I've decided type it improperly is something called a sp just a really good free all rounder comes in condensed as well, which is really cool. I'm just going to use the regular plus. We've done this before, but it's good to kind of recover these things. Little minus you can download them now to start using them on your computer, but to use them on your website, you use the embed. I want to customize it because I've decided to use regular and bold and none of the other ones. Okay, so I'm gonna embed it. I'm gonna grab you copy that goes into a head tag. So as long as it's before the closing of the head, there you go. You notice on this website, I'm only so I guess it's kind of simple website, but I've decided instead of using like a display font or a Syrah font, I'm just using the bold and the light version to get away with kind of like trying to organize the hierarchy of information. So I got the font. Let's apply it. So what I'm gonna do is I'm going to play to everything, you remember how to do that. Everything in this document, I want to be a SAP, that's right, you do it to the body. Okay, so the body tag here is going to be a font family. Okay. And I'm going to grab this from family. Save it. Let's have a little look and our preview. There you go. It's the right the right font at least let's pick a size and color and some padding. I'm going to check my mock up. You are a font size of now, I'm going to create my own one. Okay. Because I don't want to do all p tags this. I want the p tags that are inside the columns to do this thing actually could probably do it to the column, everything inside of them. But we'll do it this way. Let's go color. It's going to be white. Let's do our font size. Mhm. Okay. Remember calculator, It is going to be 14 times .06-5. Random. Okay. And where is he? That's gonna be it. And it's going to be Reames, we're gonna do some padding and we'll do our fancy all the way around. So top is going to be no idea. Okay, and side to side is going to be no idea. Good guesses. Let's have a look. Yeah, it's all right. It's not looking as kind of defined as that. So let's add a bit more I guess I'll show you this because I I I could go through and before the class and I guess write this out on a note for myself to make it seem smoother. But this is the kind of stuff that I end up doing, I'm like no back here, no back here. Testing trialing. Okay, so maybe 25 for the height. Oh that'll do for me. Okay. You'll notice that our ball went away. You might have noticed already. I just noticed there. Okay. Is why? Because we're trying to apply ah I can't wait, that doesn't exist. This one uses 700, not the word bold. Some points used bold. Okay, assumed that was it. Just make sure refresh right click. Why are you not loading now? Soapy first line coal. That is all still true. That is all still true. Alright confession time I was gone for a big five minutes. They're trying to work out what happened. You might already noticed it. Okay it's a syntax problem. Okay the problem is this guy was missing his little I am a class full stop in front of him, jesus took me a little while though and I guess I want to leave this in because it happens to everybody and I'll kind of go I'll kind of give you the skinny version of what I tried to do to fix it and how I eventually did it. So because basically work backwards and you go or what was the last thing I did and I was like that was the last thing I did so let's just turn that off, so remember command forward slash on mac, control four slash mp and adds it to commenting. It means it turns it off, so it's not read by the browser anymore, so it's as good as the leading it except it's still there and you go through and I'm like, great, well actually we'll add that fixed problem, so that was the problem, right, we'll ignore that. So I turned it off and it was still not doing, it was like, okay, so with it on, it doesn't work with it off, doesn't work, so it's not you. So I was like, all right, maybe I need to go and I keep turning things off, okay? And then I'm like up here, maybe I need to set the font weight up here to be 401st, okay, 400 then later on, turn it to that didn't work either. Okay, so I was just kind of messing about and eventually I get to the point where I'm like, no idea, nothing visually. So I just started typing it out. Okay, so turn that on and off. Didn't work. And then I'm like, okay let's re type it. So I just went through and I started typing and instantly you can start to see, you know, okay, it's one character out already, and I was like, God, jeez, that was it. Okay, don't lose your full stops or your periods. Alright, Are we back? We are back, I'm gonna turn this back on, you can see how it's nice to just turn this stuff on and off your back, your back. We're looking good. Another thing we'll do is it's jammed together because we're using a CSS reset. So this column P is going to have a line height as well. As long as it's above one line height, it's a good place to get started. 1.5 rem two big, 1.25, awesome. Actually, in this case, as long as it's above that, not one, it's as well as long as it's above whatever the font sizes being said. Okay, so as long as it's above .8, it will get bigger, anything less than that and it will get smaller, negative line height. Not something that I've done. All right now, I'm going to go through and just keep adding to these boxes. Okay? So you can skip along, I'm just going to copy and paste but you can hang around if you like. You never know what will dig up in terms of shortcuts or getting lost and fixing it. I'm going to get a view. I'm actually might close this down now. Get a full view, make it a little easier. I'm gonna use this p tag repetitive lee, I'm going to copy it. I'm going to use my multi cursor to go. You holding down my queue holding down my option key on a Mac old key on a pc, grabbing all of these guys, that guy there and pasting them in. Hopefully it should all still work if I patient in the right place. Nice. The benefit of the first line class rather than wrapping this first P tag and maybe having to pee tags in here and just putting a star on the first one. Is that if the text gets longer or changes so one's branding, let's actually make this If you put them more than one Lauren Ipsum. Okay, so Lauren, we're doing a test together. If I put in eight words again, do you get different Lauren ipsum? No, exactly the same every time. So ah Alright my high school typing class um breast. It's okay and it's hard, I can't see my fingers. Alright, but we've got this third one and there we go because it is doing the first line, it doesn't matter what you type in there, it's going to be bold, which is handy, be sweet if you could do kind of a grip style style where you can kind of get the first word. Hey hope that's all we wanted to do a little production video though. We kind of started off learning some cool CSS and then we went on a little bit of a journey but we're here, we made it, get onto the next video