Right Aligning Inline-Block Elements in CSS

Let's align the element to the right edge:

html<div class="parent">
  <span class="child">text</span>
</div>
css.parent {
  text-align: right;
  padding: 10px 0;
  border: 1px solid red;
}
.child {
  display: inline-block;
  padding: 10px 20px;
  border: 1px solid green;
}

Результат:

Задание 1

Given a div inside some parent:

html<div class="parent">
  <div class="child">text</div>
</div>
css.parent {
  padding: 10px 0;
  border: 1px solid red;
}
.child {
  padding: 10px;
  border: 1px solid green;
}

Convert the child div to an inline-block element, then right-align it to the parent.

Задание 2

Modify the previous task so that the div is not pressed tightly against the right edge by adding right padding to the parent element.

Задание 3

Modify the previous task so that the div is not pressed tightly against the right edge. To do this, give the child element a right margin.

Задание 4

A link is given inside some parent:

html<div class="parent">
  <a href="" class="child">text</a>
</div>
css.parent {
  padding: 10px 0;
  border: 1px solid red;
}
.child {
  width: 100px;
  padding: 10px;
  border: 1px solid green;
}

Convert the link to an inline-block element, then right-align it to its parent.

Задание 5

Modify the previous task so that the text inside the link is centered within that link.