Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does the tag "div.img img" mean?

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>
like image 745
Sasha Avatar asked Jun 20 '11 00:06

Sasha


People also ask

What does IMG mean in CSS?

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.


3 Answers

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>
like image 102
TimFoolery Avatar answered Oct 04 '22 17:10

TimFoolery


It means

Select any img element
that is a descendant of a div element with the class img.

The img class has no special meaning. It just looks a little confusing in this example.

like image 43
alex Avatar answered Oct 04 '22 17:10

alex


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.

like image 37
Jake Petroules Avatar answered Oct 04 '22 16:10

Jake Petroules