The perimeter of a rectangle is the sum of its side lengths.
A rectangle is special in that sides opposite one another have equal length. So if [tex]x[/tex] is the length of the horizontal sides, the total perimeter of the rectangle is
[tex]4\,\mathrm{cm} + 4\,\mathrm{cm} + x\,\mathrm{cm} + x\,\mathrm{cm} = (8+2x)\,\mathrm{cm}[/tex]
We're given the perimeter is actually 18 cm, so
[tex]8+2x = 18[/tex]
Solve for [tex]x[/tex].
[tex](8 + 2x) - 8 = 18 - 8[/tex]
[tex]2x = 10[/tex]
[tex]\dfrac12 \cdot 2x = \dfrac12 \cdot 10[/tex]
[tex]\boxed{x = 5}[/tex]