Dino Geek, try to help you

How to adjust height and width of elements in CSS?


In CSS, you can adjust the height and width of elements using the `height` and `width` properties.

For instance:
```
div { height: 100px; width: 50%;
}
```
In the above CSS rule, the height of `div` elements would be 100 pixels and the width would be 50% of the parent element.

You can use different measurements for these properties such as:

- Pixels (`px`) for absolute measurements.
- Percent (`%`) for proportional measurements relative to the parent element.
- Viewport height (`vh`) or viewport width (`vw`) for proportional measurements relative to the viewport or screen size.
- em or rem for measurements relative to the font size.

An Example of `vh` and `vw`:
```
div { height: 50vh; width: 50vw;
}
```
In the above CSS rule, the `div` will cover 50% of the viewport’s height and width regardless of the size of the viewport.

An Example of `em`:
```
div { height: 2em; width: 3em;
}
```
In this CSS rule, the `div` height and width will depend on the size of the element’s font. One `em` is equal to the current font size. If you set the font size to 16px, for instance, then the `div` would be 32px tall and 48px wide.

Note: If you want to include padding, border and margin into the element’s size, you can use the `box-sizing` property and set its value to `border-box`.

For example:
```
div { box-sizing: border-box; height: 200px; width: 200px;
}
```


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use