Up until now, we have not cared much about the dimensions of the elements we have worked with. In this lesson, we will take a look at how you easily can define the height and width of an element.
- width
- height
Setting the width [width]
With the
width
-property, you can define a certain width of an element.
The simple example below provides us with a box wherein text can be typed:
div.box {
width: 200px;
border: 1px solid black;
background: orange;
}
- Show example
Setting the height [height]
In the example above notice how the height of the box is set by the content of the box. You can affect the height of an element with the property
height
. As an example let us try to make the box in the example 500px high: