From the course: Responsive Layout

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Units

Units - HTML Tutorial

From the course: Responsive Layout

Start my 1-month free trial

Units

- [Instructor] There are many different units you can use to set the width and height of elements with CSS. Pixels is the most common for webpages. This is an absolute length, and it's always going to be the same size no matter what else you do in your code. So going into my code here, on line nine, I'm going to style the div with a width of 400 pixels. So, going over here to refresh, you can see that that's a size that stays the same even if I change the width of the browser window. We also have some relative units, which means their length can vary. Using relative units is a key part of making layouts responsive so that the content of a page can fit in any size view port. One relative unit is percent. Percent is calculated in relation to the elements containing element. So going into the code, I'm gonna give this div a width of 75%, so on line 10, I'm just going to change the width, save, and refresh, so now when I change the width of the browser window, that box is always going to…

Contents