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. http://hammernailbuilder.com/
Tell me what CSS making the text “New York” on the left side of the page?
Thanks in advance.
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.
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).