Alt öğe satır içi ise (örneğin a div, tablevb. Değil ) onu a divveya a içine psararım ve sargının metnini css özelliğini hizalayın.
<div id="container">
This text is aligned to the left.<br>
So is this text.<br>
<div style="text-align: center">
This <button>button</button> is centered.
</div>
This text is still aligned left.
</div>
Aksi takdirde, öğe sabit genişliğe sahip bir bloksa ( display: blockörneğin a divveya a p), kenar boşluğunu sol ve sağ css özelliklerini otomatik olarak ayarlardım.
<div id="container">
This text is aligned to the left.<br>
So is this text.<br>
<div style="margin: 0 auto; width: 200px; background: red; color: white;">
My parent is centered.
</div>
This text is still aligned left.
</div>
Elbette text-align: centeriçeriğini de ortalamak için sarıcı öğeye a ekleyebilirsiniz .
IMHO onun OP sorun için gitmek için yol değil ama çok yararlı bu bağlantıyı kontrol emin olun çünkü konumlandırma ile uğraşmak olmaz .