html centering code example
Example 1: css center image
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
Example 2: css center horizontally and vertically
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Example 3: centering in html
<style>
element
{
text-align: center;
}
</style>
-------------------------------------------------------------------------------
style.css
element
{
text-align: center;
}