Search code examples
csscss-selectorstext-align

How could I write this more succinctly?


How could I re-write this to where I'm not repeating text-align: center; several times?

section.info h2 {
    text-align: center;
}

section.info h5 {
    text-align: center;
}

section.info p {
    text-align: center;
}

Solution

  • Actually, since text-align is an inherited property, you can affect the section as a whole by applying the style to the parent element:

    section.info { text-align: center; }