CSS width

The width property in CSS is used to set the width of an element. You can set the width of elements such as <div>, <span>, <p>, <img>, <a>, etc. This property is essential for controlling the layout of your webpage.

The syntax for using the width property is:

selector {
    width: value;
}

Where value can be specified in pixels, percentage, or other units like em, rem, vw, etc. Here are some examples to help you understand how the width property works:

Result:
This is a div element with a width of 200 pixels.

In the example above, the width property is set to 200px, which makes the <div> element 200 pixels wide.

Result: Example Image

In this example, the width property is set to 50%, which makes the <img> element take up half of its parent container's width.

You can also use the width property to create responsive layouts by using percentage values. This allows your elements to adjust their width based on the screen size or parent container.

Experiment with different value units and see how they affect the width of elements on your webpage!