ChrisB: p+img -> andere Formatierung

Beitrag lesen

Hi,

Wenn aber das Bild das erste Element einem <p> ist, soll der margin-top wegfallen, damit das Bild auf gleicher Höhe wie der Text (rechts daneben) beginnt.

Eigentlich dachte ich, dass dies so funktionieren sollte:

p+img.bild{

margin-top: 0;
}


>   
> Dem ist leider nicht so.  
>   
> Was mache ich falsch  
  
Du hast den falschen Selektor gewählt.  
+ ist der [adjacent sibling selector](http://www.w3.org/TR/CSS21/selector.html#adjacent-selectors) - "[E1 + E2] The selector matches if E1 and E2 share the same parent in the document tree and E1 immediately precedes E2"  
  

> bzw. wie funktioniert's?  
  
<http://www.w3.org/TR/CSS21/selector.html#first-child>  
  
MfG ChrisB  
  

-- 
“Whoever best describes the problem is the person most likely to solve the problem.” [Dan Roam]