3

In this answer, the last selector (ul li a:hover { color: white; }) is redundant, as its values match what would be provided for ul li a { color: inherit; }. Try removing the last selector for yourself to verify this is correct.

I made a suggested edit, removing that selector with the comment "remove redundant code), which was rejected. If you read the comments, I point out that "the ul li a:hover selector is redundant in this, as it's still using the same color." The original answerer(?) responded that "It should go without saying, so the edit would not be necessary. ... it doesn't improve the answer in any way".

Maybe it's just me, but how does removing redundant code not improve an answer, especially if "it should go without saying"? To me, this makes no sense.

It's worth noting that this did not go through the queue, and was presumably the poster that rejected the edit.

Seeking thoughts on whether this should have been approved, as it prevents people from using redundant code.

10
  • @KevinB Yes, as the intent is to provide for inheriting the color. Setting the color explicitly (in the final selector) defeats that purpose.
    – jhpratt
    Commented Nov 15, 2017 at 21:46
  • No I'm not? The outcome is the same - the link text will be white whenever the <li> is hovered.
    – jhpratt
    Commented Nov 15, 2017 at 21:50
  • The problem there is you use // to separate the sections. CSS only has block-style comments :)
    – jhpratt
    Commented Nov 15, 2017 at 21:54
  • Yeah, I initially only tested it in an "answer" that wasn't posted.
    – jhpratt
    Commented Nov 15, 2017 at 21:55
  • 3
    i wouldn't be against such an edit, but... the owner of the answer isn't wrong for rejecting it, it's their answer after all.
    – Kevin B
    Commented Nov 15, 2017 at 21:55
  • I totally get that. The purpose of my edit was just to remove (literally) useless code, while still preserving the intent.
    – jhpratt
    Commented Nov 15, 2017 at 21:56
  • 8
    It might be better to start out with adding comments to the answer. Commented Nov 15, 2017 at 23:07
  • 2
    Or you could just post an answer yourself, saying something like: Whilst the answer from X does provide a solution it contains redundant code, see my code for a cleaner solution.
    – Luuklag
    Commented Nov 16, 2017 at 7:51
  • 5
    @Luuklag: No, I'd advice against that. If all you're changing is to remove 3 lines of code, a comment saying "those lines don't do anything" is plenty. Don't duplicate the rest of the answer.
    – Cerbrus
    Commented Nov 16, 2017 at 8:16
  • 2
    That CSS might be redundant for this one example here on Stack Overflow, but it's not hurting anything, and may actually have some relevance once the OP moves the corrected CSS back into their full project. Some people just like to be explicit. I would have rejected this edit as well.
    – Cᴏʀʏ
    Commented Nov 16, 2017 at 20:11

1 Answer 1

1

Subjective though in most cases, no.

In most cases only the relevant code is provided to help people providing an answer stay focused.

If all of the code is provided and (in the case of CSS) this rule was not clearly an exception to an earlier rule then yes.

If you're not certain don't blindly edit. Many of my own questions have been edited in to something entirely different and then two seconds later marked as a duplicate against (the original) unrelated question(s). It is always better to do fewer things decisively than many things foolishly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .