/    Sign up×
Community /Pin to ProfileBookmark

Quick centering layout question

Hey everyone,

I have a quick question that I thought might be more efficient to just post then to Google…

I’m reading a CSS book, and in an example the author shows how to bypass the traditional “container” div to center the layout. His solution: text align: center the html selector, and set body selector margin to: 0 auto, and set a 770 width. I get the body rule, im just uncertain why i have to text align center the html selector?? It seems redundant to me, but it could be my newbie-ness. To me, the browser results look the same with or without this rule applied. Any thoughts? Thanks!

— example —

html {
text-align: center;
}

body {
width: 770px;
margin: 0 auto;
text-align: left;
}

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@Major_PayneOct 15.2008 — One is for IE and related engine driven browsers. The other for all the other good browsers. ?
×

Success!

Help @NoAssmblyReqdGA spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...