How does style elements such as “color” in CSS apply to elements like img?


Tags: html,css

Problem :

I am currently reading a book on HTML to develop websites and I came across an exercise that required me to highlight the elements in a tree diagram that would be affected by the style rule

div#intro{color: red;}

Here is an image of the solution http://i.imgur.com/y9kYlBw.jpg. I don't quite agree with it because I don't think you can give an img element the color red. Is the solution incorrect or is it my understanding of inheritance incorrect?



Solution :

Well any text associated with the image will be red. If I don't provide a src, for instance, but provide alt text... the alt text will be red.

Look at this fiddle

HTML

<div id="red">
    <img alt="This is my alternate text" />
</div>

CSS

#red {
    color: #F00;
}

    CSS Howto..

    How to remove excess space added with \n

    how to make a navigation 100% width within an header wrapper

    How to Make Certain Phrases Appear on One Line Regardless of Screen Size

    How do we change the color and size of dingbat unicode characters in mobile Safari? (html entities)

    How can I apply a font type to everything using css

    How to add a Google icon font to pseudo :before

    CSS Shadows (how to get rid of top shadow?)

    How can I get css pseudo element :checked to work in IE7 + IE8?

    repeated divs loaded by angular could have different contents, how can I make them have automatically adjusted heights?

    CSS : How to add an absolute div to a scrollable background? [closed]

    Showing responsive menu link that is not shown in regular navigation menu

    How to create animated border on hover

    How to remove margin on horizontal list line break?

    jQuery hide/show issue with offset

    A plugin or tool to show what elements on a page are effecting other elements?

    How to center a navigation bar properly? [closed]

    How do you explain this div spacing issue?

    How to add another line on overflow in a text input?

    How to fit a dynamic PHP form in a div (to be able to fit fullpage.js)?

    How to hide elements with css using checkboxes: different outputs according to element id or class?

    CSS: How to add borders of different colors to input radio buttons labels?

    How to change cursor on the NextGen Gallery Slideshow in Wordpress

    PhoneGap: How to get iPad specific CSS to work?

    HTML/CSS - How do I make divs to size according to their contents?

    How to create a image transition hover effect with css without breaking the grid layout

    Javascript how to use external Css sheet

    jquery: how to determine if a style is set via css class or hardcoded by style attribute? [duplicate]

    How can I center using percentages?

    How to target Microsoft Edge with CSS? [duplicate]

    How to push a div from the top in percentage with css?