HTML & CSS for Absolute Beginners: Text alignment
Key Takeaways
Demonstrates text alignment using HTML and CSS
Full Transcript
now if we look at our design right here especially the title uh that my head was just on top of we can see that the title is centered and our logo is centered right here uh on that page and so it's want to talk a little bit about text alignment today so we can continue getting uh this project coming together and text alignment is a very simple property on the title that's right there we can come in and just say text align and say Center and if I do that it will become centered Now the default value for text align is actually start and if I do a start you'll see it goes back to the start and that does mean if you come and you say end it will go on and move over to the end instead so we have start for the beginning M uh center for the center and end to go on the other end and so I'm going to bring that back to being a start right there and hit refresh uh or not a start I should say it should be a center right there and that goes in the middle now this might seem a little bit weird if I come look all the way up here where I have my image and we have the header right here uh even though this is an image image If You by default images work with text alignment and eventually you might end up with there you know we're going to be looking at more layout tools and other things that are going to change the game a little bit but if you just have an image that you need centered and you don't have to do anything else with it you can just Center that image by selecting the parent of the image if you select the image itself and you do a text align Center you're sort of saying that the image is centered within its own space so that won't work but if you select the parent so in this case the header so let's come up all the way up here and say the header has a text align of Center and I hit save on there the image will go to the middle the reason this works is because images are inline elements just like our strong and our M tags so they can work as if they're in text and I can actually just to highlight that I could take my image I'm going to copy that I'm going to go in the middle of my logo here or not my logo but of my heading and bring in the logo and so if I hit refresh you can see that my image can live within the text so by default text alignment does work on images so I'm going to undo that because I don't actually want to have uh my logo inside of my heading but there we go but just yeah a very quick and easy way if you just have an image on its own don't select the image itself but select the parent of the image text to line Center will Center that image so that worked out really well uh I do want to mention that you might have already come across or if you do future learning and tutorials and other stuff uh you will see times let's go on my H2S right now just to have a different selector uh you might see a text align of left which is we're not actually changing anything right which will if I change that it'll go over to the right uh so left and right are the original properties we had for it and more recently CSS has put in a big effort into having what we call logical properties so that would be for having a the the start and the end like that and so end and in this case right would be the same the reason we have those these new logical properties is because some languages are left to right and other languages are right to left so languages like Arabic Hebrew farsy among many others are right to left languages and you might have a site that's multilingual in which case you're very happy to have this end so if the person's switching the Lang Ang it will switch along with it but also people will use tools to translate your website sometimes and it's nice if it actually aligns the text properly because if you had to text align end on something that should in a language that goes the other direction it should actually switch to the other side and the way we can do that and this doesn't really make sense cuz we're in an English website but if you go on your HTML element all the way at the top you can put a dur for direction di is equal to and then I can say it's actually going to be right to left RTL right to left and if I do that we're switching the alignment of everything on the site so the default has all gone right to left but that means on elements where we were using a text align end it's actually switched that over because now the end is on the other side and even if all of the content you're doing is just going to be in a language that is left to right which obviously I'm doing it in English but there's most languages in the world are left to right languages where you could come here and actually say left to to right if you wanted to and now it will go back to the uh left to right but if you don't include one that is the default and so by have you know you might be saying everything I'm doing is just going to be left to right I'd still encourage you to use the logical properties we're going to be looking in a few other ones going uh into the future uh just because first of all it makes it's a good habit to get into it's not any more work for yourself and it ends up being something that probably ends up making your life a little bit easier if ever you run into the situation where you need to and for users who are using plugins and other things to change the language of your site they're going to be very happy that you use logical properties instead so start for the regular alignment end to go all the way to the other side and then a center is always Center so nothing too hard to remember there
Original Description
🎓 Enroll in this course for FREE - get additional lessons, written content, interactive exercises, and more: learn.kevinpowell.co
📂 Get the course files here: https://www.dropbox.com/scl/fo/kusdjekuytcaa3of0vtd4/AChRHcF13pNi93JWusfLW9A?rlkey=tbrbxnabsi52u6onal9rh7fwm&st=iyo2wujq&dl=0
Learn to build websites from scratch - even if you've never written a line of code before. This hands-on course teaches you the fundamentals of HTML and CSS, the building blocks of the web. You'll start with the basics and progress step-by-step to creating your own responsive websites. Perfect for complete beginners who want to start their web development journey.
#css
--
Come hang out with other dev's in my Discord Community
💬 https://discord.gg/nTYCvrK
Keep up to date with everything I'm up to
✉ https://www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 https://www.twitch.tv/kevinpowellcss
---
Help support my channel
👨🎓 Get a course: https://www.kevinpowell.co/courses
👕 Buy a shirt: https://teespring.com/stores/making-the-internet-awesome
📽️ Join as a channel member: https://youtube.com/@KevinPowell/join
💖 Support me on Patreon: https://www.patreon.com/kevinpowell or through YT memberships: Join this channel to get access to perks:
https://www.youtube.com/channel/UCJZv4d5rbIKd4QHMPkcABCw/join
---
My editor: VS Code - https://code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my YouTube channel, make sure to follow me on Instagram and Twitter.
Bluesky: https://bsky.app/profile/kevinpowell.co
Codepen: https://codepen.io/kevinpowell/
Github: https://github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Kevin Powell · Kevin Powell · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How to create an awesome navigation bar with HTML & CSS
Kevin Powell
Improve your CSS by Keepin' it DRY
Kevin Powell
HTML & CSS for Beginners Part 6: Images
Kevin Powell
HTML & CSS for Beginners Part 7: File Structure
Kevin Powell
HTML & CSS for Beginners Part 4: Bold and Italic text and HTML comments
Kevin Powell
HTML & CSS for Beginners Part 5: Links
Kevin Powell
HTML & CSS for Beginners Part 3: Paragraphs and Headings
Kevin Powell
HTML and CSS for Beginners Part 1: Introduction to HTML
Kevin Powell
HTML and CSS for Beginners Part 2: Building your first web page!
Kevin Powell
HTML & CSS for Beginner Part 8: Introduction to CSS
Kevin Powell
HTML & CSS for Beginners Part 9: External CSS
Kevin Powell
HTML & CSS for Beginners Part 10: Divs & Spans
Kevin Powell
HTML & CSS for Beginners Part 11: Classes & IDs
Kevin Powell
HTML & CSS for Beginners Part 12: The CSS Box Model - Margin, Borders & Padding explained
Kevin Powell
HTML & CSS for Beginners Part 13: Background Images
Kevin Powell
HTML & CSS for Beginners Part 14: Style Text with CSS
Kevin Powell
HTML & CSS for Beginners Part 15: How to style links
Kevin Powell
HTML & CSS for Beginners Part 16: CSS selectors and Specificity
Kevin Powell
HTML & CSS for Beginners Part 17: How to Create and Style HTML Lists
Kevin Powell
HTML & CSS for Beginners Part 18: How Floats and Clears work
Kevin Powell
HTML & CSS for Beginners Part 19: Colors with CSS - hex, rgba, and hsla
Kevin Powell
HTML & CSS for Beginners Part 20: How to center a div
Kevin Powell
HTML & CSS for Beginners Part 21: How to create a basic website layout - the HTML
Kevin Powell
HTML & CSS for Beginners Part 22: How to create a basic layout - the CSS
Kevin Powell
How to Create a Responsive Website from Scratch - Part 1: The HTML #Responsive #HTML5
Kevin Powell
How to Create a Responsive Website from Scratch - Part 2: The Header and Hero area #Responsive #CSS3
Kevin Powell
How to Create a Responsive Website from Scratch - Part 3: The About Section #Responsive #CSS
Kevin Powell
How to Create a Responsive Website from Scratch - Part 4: Building a Responsive Portfolio Section
Kevin Powell
How to Create a Responsive Website from Scratch - Part 5: Call To Action and Footer #CSS #Responsive
Kevin Powell
Tutorial: Learn how to use CSS Media Queries in less than 5 minutes
Kevin Powell
End of the year upate and what's coming to my channel to start the new year
Kevin Powell
Create a CSS only Mega Dropdown Menu
Kevin Powell
CSS Tutorial: Outline and Outline Offset
Kevin Powell
CSS Blending Modes
Kevin Powell
Parallax effect | 2 different ways to add it with jQuery
Kevin Powell
CSS Units: vh, vw, vmin, vmax #css #responsive #design
Kevin Powell
How to Create a Website - Complete workflow | Part 01: Intro + Setting things up
Kevin Powell
100 Subscribers speed coding bonus video
Kevin Powell
How to Create a Website - Complete workflow | Part 02: The Markup #HTML
Kevin Powell
How to Create a Website - Complete workflow | Part 03: Sass Variables and a Mixin #Sass
Kevin Powell
How to Create a Website - Complete workflow | Part 04: Setting up the hero and header
Kevin Powell
How to Create a Website - Complete workflow | Part 05: Typography & Buttons
Kevin Powell
How to Create a Website - Complete workflow | Part 06.1: Building the navigation with Flexbox
Kevin Powell
How to Create a Website - Complete workflow | Part 06.2: Making the nav work with jQuery
Kevin Powell
Redesigning & Coding My Website #CreateICG
Kevin Powell
How to Create a Website - Complete workflow | Part 07: Starting the flexbox grid
Kevin Powell
How to Create a Website - Complete workflow | Part 08: Promo & Problem shooting!
Kevin Powell
How to Create a Website - Complete workflow | Part 09: The CTA and Footer
Kevin Powell
How to Create a Website - Complete workflow | Part 10: Making it responsive
Kevin Powell
How to Create a Website - Complete workflow | Part 11: Making it responsive con't
Kevin Powell
How to Create a Website - Complete workflow | Part 12: Putting the site online
Kevin Powell
Create a Custom Grid System with CSS Calc() and Sass
Kevin Powell
CSS em and rem explained #CSS #responsive
Kevin Powell
Should you use Bootstrap?
Kevin Powell
How to add Smooth Scrolling to your one page website with jQuery
Kevin Powell
Let's learn Bootstrap 4
Kevin Powell
How I approach designing a website - my thought process
Kevin Powell
Build a website with Bootstrap 4 - Part 1: The setup
Kevin Powell
Build a website with Bootstrap 4 - Introduction
Kevin Powell
Build a website with Bootstrap 4 - Part 2: Customizing Variables
Kevin Powell
Related Reads
📰
📰
📰
📰
I built a landing page with Three.js, vanilla JS, and zero frameworks — here's what I learned
Dev.to · Ayush Shekhar
Part 1: Why I Rarely Use useEffect Anymore (and what I use instead)
Dev.to · Alejandro
HTML Canvas Cheat Sheet for Pixel Art & Image Effects
Dev.to · lemon
Draw Pixel Art with Vanilla JS — A Step-by-Step Guide
Dev.to · lemon
🎓
Tutor Explanation
DeepCamp AI