Hi makenzi.exc,
Use the textAlign property of style
The textAlign property sets or returns the horizontal alignment of text.
It has the following possible values.
left, right, center, justify, initial, inherit.
left - Aligns the text to the left. This is default.
right - Aligns the text to the right.
center - Centers the text.
justify - The text is justified.
initial - Sets this property to its default value.
inherit - Inherits this property from its parent element.
Refer below example.
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
body { font-family: Arial; font-size: 10pt; }
</style>
</head>
<body>
<div id="dvContent">
<input type="button" value="Align Center" onclick="AlignCenter()" />
<hr />
Welcome to ASPSnippets
</div>
<script type="text/javascript">
function AlignCenter() {
document.getElementById("dvContent").style.textAlign = "center";
};
</script>
</body>
</html>
Demo
Screenshot

Downloads
Download Sample