solidcodes — 2013-09-28T06:33:55-04:00 — #1
I know this is basic,
But I can't find the right CSS element that causing this.
As you can see the text "New York" is on the left side of this page.
Tell me what CSS making the text "New York" on the left side of the page?
Thanks in advance.
pbsonawane — 2013-09-28T07:31:31-04:00 — #2
it must be taking default alignment
if you want to align it to center or right, you can just use div tag like this
<div align="center">New York</div>
<div align="right">New York</div>
solidcodes — 2013-09-28T07:46:10-04:00 — #3
Thanks dude, but I want to know which CSS element causing it.
The CSS codes is not from me.
paulob — 2013-09-28T07:59:06-04:00 — #4
The text is on the left because that is the default setting and there are no other rules in place to change the default.
If you want to center the text then either place a div around the text and use text-align:center in the css via a class. (Don't use div align="" or the <center> tag as they are deprecated and are code from the last century) . Alerntatively add text-align:center to .content but of course that will affect all text in .content.
solidcodes — 2013-09-28T12:11:04-04:00 — #5
How to center properly not text?
Thanks in advance.
paulob — 2013-09-28T12:28:58-04:00 — #6
To centre fixed width block elements horizontally you just add margin:auto (specifically left and right margins should be auto). The element needs to have a width defined. If there is no width then the element is 100% wide and effectively there is nothing to centre.
To centre inline-block elements (or text) just add text-align:centre on a parent div.
In some cases you may have want width-less containers centred and then you can add display:table and margin:auto to the element and it will be centred in IE8+ (just like a normal table would with margin:auto).