♦ CSS Height Width
♣ About CSS Height Width
Height and Width can be set form HTML elements.These properties can be set in different formats, which are tabularized below.
Below is a tabular explanation of Different Formats
Format | Functioning |
---|---|
auto | Default option, the browser determines Height and Width |
length | can be em, px, pt, cm, in, etc |
% | percentage of blocks size(Height/Width) |
initial | sets Height/Width to elements Default value |
inherit | parent's value will be copied |
♣ Example1: using pixels in CSS
In this example, pixels are used for dimensioning. Example
Input:
Output:
♣ Example2: using % in CSS
In this example, the percentage is used for dimensioning.Note that % symbol will not work for height, instead, use vh.
Example
Input:
Output:
♣ Example3: using em in CSS
In this example, em is used for dimensioning. Example
Input:
Output: