HTML/CSS/Style Basics/Tag Selector

Материал из Web эксперт
Перейти к: навигация, поиск

img in a div

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
<style type="text/css">
div img {
 display: none;
}
</style>
</head>
<body>
  <h1>header 1!</h1>
   <div><img src="http://www.wbex.ru/style/logo.png" alt=" " /></div>
  <h2>header 2</h2>
</body>
</html>



nested tag style

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
        <title></title>
<style type="text/css">
body {
  margin: 10%;
}
h1 {
  width: 216px;
  height: 72px;
  position: relative: 
}
h1 span {
  background: url(replacementimage.jpg) no-repeat;
  position: absolute;
  width: 100%;
  height: 100%;
}
</style>
    </head>
    <body>
<h1><span>span</span>header</h1>
    </body>
</html>