Content Size
The size of an element's content can be set using two properties:
- Height (
height
) - Width (
width
)
In the real world, we specify dimensions in inches [in] or feet [ft]. In programming, we often use pixels [px], where one pixel represents one point on the screen.
For reference, a typical monitor is 1920 pixels wide and 1080 pixels tall.
This means that if we were to insert an image that is 1000 pixels wide and 500 pixels high into our web page, it would be roughly half the size of the monitor and wouldn't fit entirely on a phone screen.
To set the width of all images to 1000px and the height to 500px, we would use the following CSS:
img {
width: 1000px;
height: 500px;
}
Instructions
Set the width of paragraphs (p
) to 200 pixels.
Start programming for free
3/9