Centering in CSS can be a little trying. If one was to code using the attributes margin: auto; and padding: 0px; one will still have troubles with Internet Explorer computing it correctly. In order to fix this, make sure you clarify the DOCTYPE correctly and add display: table; to margin: auto; and padding: 0px;. Sometimes IE will not render this correctly so you may need to place a set width on it. :)
If done correctly. CSS will take this:
In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends of worms and oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to eat: it was a hobbit-hole, and that means comfort.
It had a perfectly round door like a porthole, painted green, with a shiny yellow brass knob in the exact middle. The door opened on to a tube-shaped hall like a tunnel: a very comfortable tunnel without smoke, with panelled walls and floors tiled and carpeted, provided with polished chairs and lots and lots of pegs for hats and coats--the hobbit was fond of visitors. The tunnel wound on and on, going fairly but not quite straight into the side of the hill--The Hill, as all the people for many miles round called it--and many little round doors opened out of it, first on one side and then on another. No going upstairs for the hobbit: bedrooms, bathrooms, cellars, pantries (lots of these), wardrobes (he had whole rooms devoted to clothes), kitchens, dining-rooms, all were on the same floor, and indeed on the same passage. The best rooms were all on the left-hand side (going in), for these were the only ones to have windows, deep-set round windows looking over his garden, and meadows beyond, sloping down to the river.
and while using this code...
width: 70%;
margin: auto;
display: table;
padding: 0px;
Note: There are other values besides table for the display property. There are four commonly used values.
by inserting <div class="center"> into the HTML code to make it do this...
This hobbit was a very well-to-do hobbit, and his name was Baggins. The Bagginses had lived in the neighbourhood of the Hill for time out of mind, and people considered them very respectable, not only because most of them were rich, but also because they never had any adventures or did anything unexpected: you could tell what a Baggins would say on any question without the bother of asking him. This is a story of how a Baggins had an adventure, and found himself doing and saying things altogether unexpected. He may have lost the neighbours' respect, but he gained---well, you will see whether he gained anything in the end.