i understand the general idea of creating a class tag, such as .center or p.center, but what does it mean to do something like "p.center p"? i saw an example like this in creating an image gallery with css. what does the div.img img mean? thanks a bunch!
<html>
<head>
<style type="text/css">
div.img
{
margin: 2px;
}
div.img img
{
display: inline;
margin: 3px;
border: 1px solid #ffffff;
}
div.img a:hover img {border: 1px solid #0000ff;}
</style>
</head>
<body>
<div class="img">
<a target="_blank" href="klematis4_big.htm"><img src="klematis4_small.jpg" alt="Klematis" width="110" height="90" /></a>
</div>
</body>
</html>
Definition and Usage The <img> tag is used to embed an image in an HTML page. Images are not technically inserted into a web page; images are linked to web pages. The <img> tag creates a holding space for the referenced image. The <img> tag has two required attributes: src - Specifies the path to the image.
All of the answers given so far are correct, but perhaps also explaining what it isn't will help.
While div.img img { }
will affect img
elements contained in <div class="img">
elements, here are some elements that it will not affect:
<body>
<img src="klematis4_small.jpg" alt="Klematis"><br>
This image is not contained in a div, therefore it cannot possibly be
contained in a div of the class "img" and is therefore unaffected.
<div>
<img src="klematis4_small.jpg" alt="Klematis"><br>
This img element is in a div, but the div is not of the class "img",
so the img element is unaffected.
</div>
<div id="img">
<img src="klematis4_small.jpg" alt="Klematis"><br>
This img is contained within a div that has an ID of "img", but it is
also not of the class "img" and is therefore unaffected.
</div>
</body>
It means
Select any
img
element
that is a descendant of adiv
element with the classimg
.
The img
class has no special meaning. It just looks a little confusing in this example.
The div.img img
selector will style img tags inside divs with the class "img". For example:
<div class="img">
<img src="foo.jpg" alt="" />
</div>
In short, only img tags that are contained within div tags having the class img will be styled by that selector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With