Width and height of elements in CSS
To set the width and height of elements in CSS, use the width and height properties. The values of these properties are usually specified in pixels. Pixels are denoted as px and are added to the number. For example, to set the size in 100 pixels, the value of the property should be: 100px.
Let's look at how these properties work using an example. Let's set the width of some table cells to 200px and the height to 100px:
<table border="1">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
td {
width: 200px;
height: 100px;
}
:
Make paragraphs with long text in HTML code. Using CSS, set the width of all paragraphs to 300px.
The following table is given:
<table border="1">
<tr>
<td>John</td>
<td>Smith</td>
<td>200$</td>
</tr>
<tr>
<td>Nick</td>
<td>Mayers</td>
<td>300$</td>
</tr>
<tr>
<td>Alex</td>
<td>Jonson</td>
<td>400$</td>
</tr>
</table>
Set the width of this table cells to 400px and the height to 300px.