alex416 alex416 - 11 days ago 7
CSS Question

How could i make CSS apply to all in a div?

Say

<style>
#id{
text-align:center;
color:orange;
}
</style>

<div id="id">
<a href="http://url.url/">Click</a>
</div>


So I would like it to apply
color:orange;
to the
<a>
tag, but it does not, how could I do this?

The
<a>
applys, but
color:orange;
does not.

Example: Codepen example

Thanks.

Answer

Usually this is not necessary because color is an inherited property. However, links have a color defined by default in the user agent stylesheet, so they don't inherit. You only need to use a more specific selector than that default one.

#id, #id * {
  text-align:center;
  color:orange;
}
<div id="id">
  <a href="http://url.url/">Click</a>
</div>