Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Julie Vandebosch
10,360 PointsBootstrap containers, rows and cols always in div?
Do you always have to add rows and cols to divs? Or can you also give other elements like section, header, p, img,... the class 'container', 'row' or 'col'?
1 Answer
Bradley Weston
Courses Plus Student 360 PointsNo, you can use what-ever element you'd like, for inline and inline-block elements you may want to add display: block; else there may be some undesired behaviour.
Preferably a div because its primary usage is to be a block element that contains other elements unlike the suggested p.
img elements don't have content so you're not going to put a container or row class on it.
header you might use this contain a container and then a row inside depending on how you're planning to structure everything common usage I see is this, is makes sense as the header can have its background, the container sets up the inner width/margins and the columns are separating that container out.
https://github.com/twbs/bootstrap/blob/master/less/mixins/grid.less#L15
<header>
<div class="container">
<div class="row">
<div class="col-sm-6"></div>
<div class="col-sm-6"></div>
</div>
</div>
</header>
Julie Vandebosch
10,360 PointsJulie Vandebosch
10,360 PointsThanks!