CSS :: Difference between .className and div.className

css, html

Solution

The difference is that in the first class you tell that all element (`div`, `p`, `span` ...) with class `box` have that attribute. Like this:

<span class="box">test</span>
<div class="box">test</div>
<p class="box">test</p>

The second class means that only div with class `box` has that attribute

Only this elements get second class:

<div class="box">test</div>

The `selector` before the class specify which type of elements can take this class

Problem

I write a html element as below :: ``` <div class="box"> Foo box </div> ``` and write css like ``` .box { width: 400px; height: 40px; color: red; text-align: center; } or div.box { width: 400px; height: 40px; color: red; text-align: center; } ``` I want to ask that how the both css for box class is different than each other.

Original source