align left css code example

Example 1: css align center

//HTML
<div class="parent">
	<span>Hello World</span>
</div>

//CSS
.parent {
  display: flex;
  justify-content: center;
  align-items: center;
}

Example 2: center text in css

.class {
	text-align: center;
}

Example 3: css align to left

body {
  text-align: left;
}

Example 4: how to horizontal center a div in css

#inner {
  width: 50%;
  margin: 0 auto;
}

Example 5: align center css

margin: auto;

Example 6: how to center align the html element in css examples

#inner {
  width: 50%;
  margin: 0 auto;
}

# center text
.center {
  text-align: center;
  
border: 3px solid green;
}

Tags: