A: red has z-index 2, blue has z-index 1, so red wins the overlap. B: the same DOM order without z-index paints blue last.