Reputation: 1099
I have an JSP page and I'm trying to center everything. I have following HTML script below.
<html>
<head>
<title></title>
</head>
<style type="text/css">
body{text-align:center}
</style>
<body>
CONTENT HERE!<br>
My name is XXXX, and please call me XX.
</body>
</html>
When testing in web browser, it does center but the the beginning of each sentence is not aligned. How do I adjust it?
I appreciate if someone could help me.
Upvotes: 3
Views: 25271
Reputation: 45
It does not center your every content when you do text-align property in body. But you try these properties :
margin: auto;
display: flex;
justify-content: center; /* for horizontal */
align-items: center; /* for vertical */
Upvotes: 3
Reputation: 29424
You want to insert a container and center that.
→ jsFiddle
<body>
<div id="wrapper">
CONTENT HERE!<br>
My name is XXXX, and please call me XX.
</div>
</body>
#wrapper {
width: 70%; /* specify a width! */
margin: 0 auto; /* center */
}
Upvotes: 5