Div alignment

Xup guyz? This may sound stupid, buh am kinda confuse.
My question is: "IS THERE A WAY OF ALIGNING DIV WITHOUT STYLING WITH HTML i.e <div class=“alignment” align=“center”></div>. If i do this a preview on adobe device central, its not always aligned in the mobile. I was wondering if i culd do this with css. Hope u get me. TIA.

Yes. Use css. For example. Apply a class to that div and mark it up . It depends on the situation but if you have text in there, for example, just apply text-align:center to the class.

Do you want to centre the text within the div, or centre the div itself?

If you want to centre the contents of the div, Ryan has given you the answer.

If you want to align a div in the centre of the page, you need to set a width on it and then set the margins to auto.

e.g.

<div class="center">
.center {width: 20em;
margin: auto;
}

You can set the width to whatever and however you like - use ems, px, % or whatever suits.

Thanks to y’all. Am highly grateful. Lemme get back to work.

Worked Perfectly.

Cool. Those guys (and girl (?) ) are really good.

Just a question, can I create a container div for my webpage (everything) and then just use text-align center to center all children of the div?

~TehYoyo