Img Element is affected by another class but does not own the class / CSS

I was looking why my img got a margin on the right side, I did not find any margin related to the object and setting the margin to 0 didn't work. I finally found the problem. Another class named floatright img, li with a margin right 15px worked on that named img. The issue is that I don't get why. The Img has no specific class only the whole div where its in got a class but the class is angebote and has no margin in it. Deactivating the margin 15px in the console deletes not only the margin from objects who own the class floatright but also from the named img. What should I do ? I don't know why the img is affected from the margin of another class it does not even own.

Here is the problem and how I found it

 .angebote img{
    width: 250px;
    height: auto;
 }
 .floatright li, img{
    float: right;
    font-size: 10px;
    margin-right: 15px;
    list-style: none;
 }

Solution 1:

The second css rule you posted (.floatright li, img {...) selects two different things: All li elements within a parent element that has the .floatright class, AND all img elements in general. The comma seperates the selectors, the settings are valid for two different selectors.

So to remove the margin-right from your image, simply add margin-right: 0 to your .angebote img rule. Its selector is more specific than just img , so it will overrule the other CSS rule. Same for float: right: If you don't want it, add float: none to your .angebote img rule.