This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by nikita2604
almost 10 years

What is the reason behind adding <div> as opposed to <div class="">?

The supporting text of Travel, Host and Trust and Safety is placed in div as opposed to div class=””. For the Jumbotron text we only use div class=””.

Why do we use div as opposed to div class=””. Are they interchangeable?

<div class="jumbotron">
  <div class="container">
    <h1>Find a place to stay.</h1>
    <p>Rent from people in over 34,000 cities and 192 countries.</p>
  </div>
</div> 

<div class="learn-more">
  <div> *why is there div here?*
    <div>
      <div>
        <h3>Travel</h3>
        <p>From apartments and rooms to treehouses and boats: stay in unique spaces in 192 countries.</p>
        <p><a href="#">See how to travel on Airbnb</a></p>
      </div>
      <div>

Answer 538f21de282ae30fd3006846

1 vote

Permalink

Giving divs a class name will allow you to target them with CSS style rules.

In some sections you are being lead to put your divs in as you go, in preparation for future styling. In another section you will put your content in first and then wrap that in divs as needed. These are two ways to get to the same end. You are being exposed to both for the experience. That’s my opinion anyway :)

points
Submitted by Judy
almost 10 years

3 comments

S almost 10 years

But how will we refer divs for future styling if we do not give it a name using class?

Judy almost 10 years

In upcoming exercises you will be giving them names.

S almost 10 years

ok