Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChi Lun Ip
1,417 Pointsfloat+ margin VS text-align +margin
Guys I have a question over this video: Nick used "float:right + margin-right" in here and if I used "text-align:right + margin", why the words can not be displayed in the way Nick did in the video??(both have selected "nav")
2 Answers
Adama Sy
7,076 PointsBecause text-align and float are two different things and dont do the same.
Text-align can be left-aligned, which means the left edge of the text is flush with the left margin, right-aligned, centered, or justified, which means it's aligned evenly along the left and right margins.
The float property defines the side around which other elements will flow around the floated element. The floated element will remain on the float side, while other content flows around it.
so depending on what you use, you will get a different reaction on your webpage
Adama Sy
7,076 PointsWhen you see percentage , instead of pixels, (px) this means Nick have made a responsive website, he converted the margin right to percentage, using a context , this is something you will learn later on. and maybe other things were added to change the behaviour of the text, and you have not done the same to get the result. for people to understand why we need to see your code. all your code. maybe you copy and past it here
Chi Lun Ip
1,417 PointsChi Lun Ip
1,417 PointsThanks for the answer, and sorry I should have mentioned my problem was in the video "Adjust the profile pic and header". Nick applied css on "nav" with "float:right" , "margin-right:5%" &"text-align:right", and I was trying to achieve the same effect by selecting "nav" as well, applying css with "text-align:right" and margin: 50px (something like that) and could not, nav is not moving at all.
So my question is: why "nav" is not moving at all while I applied css on the margin?
Thanks for answering my newbie question, sorry for that in advance if I confused you.