¿Cómo puedo aplicar estilos a varias clases a la vez?


Quiero que dos clases con nombres diferentes tengan la misma propiedad en CSS. No quiero repetir el código.

.abc {
   margin-left:20px;
}  
.xyz {
   margin-left:20px;
}
<a class="abc">Lorem</a>
<a class="xyz">Ipsum</a>

Dado que ambas clases están haciendo lo mismo, debería ser capaz de fusionarlo en uno. ¿Cómo puedo hacer eso?

Author: TylerH, 2010-01-20

3 answers

.abc, .xyz { margin-left: 20px; }

Es lo que estás buscando.

 357
Author: Juraj Blahunka,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-16 16:19:10

Puede tener varias declaraciones CSS para las mismas propiedades separándolas con comas:

.abc, .xyz {
   margin-left: 20px;
}
 48
Author: zombat,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-01-20 05:38:23

No Repita Su CSS

 a.abc, a.xyz{
    margin-left:20px;
 }

O

 a{
    margin-left:20px;
 }
 12
Author: NiteshkumarSingh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-28 06:46:10