How do you determine a browser's width?

According to this lesson here , the container div was set to a width of 50%, which is half of the browser’s width.

How do we determine the browser’s width in order to set our containers’ widths appropriately?

As far as I know there is no way to tell, since the browsers width is determined on the users device, based on their personal preference.

Which is why you can use a mixture of percentages and pixels to determine the size of a container. Such as the following example:

div {
  max-width: 50%;
  min-width: 500px;
}

This means the container will attempt to fill up 50% of the screens width, but won’t drop below 500px wide.

1 Like