Gunnar Bittersmann: Attributvergabe in CSS

Beitrag lesen

@@Gunnar Bittersmann

table.v1 {
  .Land {
    text-align: left;
  }
}

Ähm, was irgendwie seltsam kompliziert aussieht. Warum nicht einfach

table.v1 .Land {
  text-align: left;
}

Die Sache sieht aber anders aus im Gesamtzusammenhang:

table.v1 .Land {
  text-align: left;
}

table.v1 .PLZ {
  text-align:center;
}

table.v1 .Stadt {
  text-align:right;
}

vs.

table.v1 {
  .Land {
    text-align: left;
  }

  .PLZ {
     text-align:center;
  }

  .Stadt {
     text-align:right;
  }
}

Da macht das mit dem Nesting schon Sinn.

🖖 Live long and prosper

--
“In my home, the America I love, the America I've written about, that has been a beacon of hope and liberty for 250 years, is currently in the hands of a corrupt, incompetent and treasonous administration. Tonight, we ask all who believe in democracy and the best of our American spirit, to rise with us, raise your voices against authoritarianism, and let freedom reign.”
— Bruce Springsteen, Manchester 2025-05-14