0

I want to know why .sisa span{} is not working but .sisa,span{} is working ? doesnt it mean that without the comma you are simply selecting all spans within that class ? so it should also work ?

<!DOCTYPE html>
<html>
<head>
<title> html5</title>
<meta charset="UTF-8"/> 
<style>

div.sisa{
    width: 515px;
    height: 230px;
    border: 1px solid #73AD21;
    background-color: #adfab7;
}
.sisa span{
text-align:center;

}
</style>
</head>
<body>
<form >
  <div class="sisa">
<span>Esim. postinumero tai kunta </span>

   </div> 
</form> 
</body>
</html>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
waleedd32
  • 473
  • 2
  • 9
  • 23
  • @dippas it's not about the difference between having space or not, it's about the difference between having a space or a `,` – Temani Afif May 28 '18 at 21:57

1 Answers1

1

When used with space your selector is targeting and centring the content of span but it's an inline element that fits its content so there is nothing to center. When used with , you are applying the center to the div (so you center its content including the span element) and applying the center to the span but it's useless.

So you only need this:

div.sisa {
  width: 515px;
  height: 230px;
  border: 1px solid #73AD21;
  background-color: #adfab7;
}

.sisa {
  text-align: center;
}

span {
  border:1px solid red;
}
<form>
  <div class="sisa">
    <span>Esim. postinumero tai kunta </span>

  </div>
</form>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415