css left align 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: css center

/* this will center all children within the parent element. */
.parent {
  display: flex;
  justify-content: center; /* horizontal */
  align-items: center; /* vertical */
}

Example 3: center text in css

.class {
	text-align: center;
}

Example 4: css align center vertical and horizontal

.parent-class {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

Example 5: css align to left

body {
  text-align: left;
}

Example 6: css center

// example 1 
div { display: grid; place-items: center; }

// example 3
div{ display:flex; align-items:center; }

// example 3
div { width: 100%; margin: 0 auto; }

Tags:

Html Example