By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,713 Members | 1,326 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,713 IT Pros & Developers. It's quick & easy.

div.float versus .float

P: n/a
Hello,

I was reading an article and I can't figure something. I have:

div.float {
float: left;
}

And the HTML:

<div class="float">
<p>caption 1</p>
</div>

What is the difference of having:

div.float {
float: left;
}

or just

..float {
float: left;
}

Thanks,
Miguel

Nov 26 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Els
shapper wrote:
Hello,

I was reading an article and I can't figure something. I have:

div.float {
float: left;
}

And the HTML:

<div class="float">
<p>caption 1</p>
</div>

What is the difference of having:

div.float {
float: left;
}

or just

.float {
float: left;
}
As long as you only have one type of element with class="float", there
is no difference. If you'd have a div with class="float" and also
another element with that class, for instance <p class="float">, then
there would be a big difference :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Nov 26 '06 #2

P: n/a
Ah,

got it. That might come handy. :-)

Thanks,
Miguel

Els wrote:
shapper wrote:
Hello,

I was reading an article and I can't figure something. I have:

div.float {
float: left;
}

And the HTML:

<div class="float">
<p>caption 1</p>
</div>

What is the difference of having:

div.float {
float: left;
}

or just

.float {
float: left;
}

As long as you only have one type of element with class="float", there
is no difference. If you'd have a div with class="float" and also
another element with that class, for instance <p class="float">, then
there would be a big difference :-)

--
Els http://locusmeus.com/
accessible web design: http://locusoptimus.com/
Nov 26 '06 #3

P: n/a
Els wrote:
shapper wrote:
>What is the difference of having:

div.float {
float: left;
}

or just

.float {
float: left;
}

As long as you only have one type of element with class="float", there
is no difference. If you'd have a div with class="float" and also
another element with that class, for instance <p class="float">, then
there would be a big difference :-)

Furthermore, div.float is more specific than .float. Selector
specificity impacts on the cascade order:
http://www.w3.org/TR/CSS21/cascade.html#cascading-order

David
Stardate 6904.7
Nov 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.