Make WordPress Core

Changes between Version 2 and Version 3 of Ticket #50909, comment 14


Ignore:
Timestamp:
08/12/2020 06:38:12 PM (6 years ago)
Author:
jeslen

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #50909, comment 14

    v2 v3  
    3030CSS, a Cascading StyleSheet, is read by the browser top to bottom. If there are identical selectors in the same or other CSS files, whichever one is at the bottom will take priority. Stylesheets added to a page one after another will be treated as if they were just added on to the end of the first.
    3131
    32 For example, if a style sheet has `img { max-width: 100%; height:auto; }` and then the same sheet later has `img { height: 100%; }` (''notice the heights are different''), the browser will render all images with `max-width: 100%` and `height: 100%`.
     32For example, if a stylesheet has `img { max-width: 100%; height:auto; }` and then the same stylesheet later has `img { height: 100%; }` (''notice the heights are different''), the browser will render all images with `max-width: 100%` and `height: 100%`.
    3333
    3434What's happening here is the first `img` selector instance is setting both the `max-width` and `height` styles, but the second instance of `img` is overriding the `height`. The browser will render the max-width style set from the first instance (`max-width: 100%`) while the height is rendered from the second (`height: 100%`).