Search code examples
htmlcsscolors

Default Color in CSS


Pretty new to this. Let's say define the following in my CSS file (no color attribute)

.time {
    border: 1px solid #666666;
    background: #555555;
    text-align: center;
    cursor: pointer;
    transition: all linear 0.3s;
    padding: 1px 2px;
    font-size: .8em;
}

and then use it like this

<div class="time" ...

Where does the text color come from? Is there a default, does it use on defined in a previous tag, ...?


Solution

  • There are 3 cases in this situation:

    1. It will take the first color of a parent if a parent has defined a color
    2. If the parent has no defined color then it will take the body or html color
    3. If html and body elements have not defines color after that it will take browser default color.