# Can we make quoted code blocks less ugly?

It is often useful to cite blocks of code, particularly when writing an answer, and you want to distinguish between code that you are proposing and code that you are discussing. However, code blocks that are inside blockquotes currently look rather ugly, with non-uniform yellowish margins around a gray block.

Here's a screenshot:

What visual design could work better?

• I don't think the current design is that bad. But then again, I'm not really known for my design skills... – Simon Forsberg May 12 '15 at 18:29
• I've used that feature and recently I've started to find it make answers bigger than what they really need. We need to identify what part of the codes we are reviewing, but it's make a lot duplication. – Marc-Andre May 12 '15 at 18:30
• While we are talking about this, it'd be absolutely stellar if we could get code blocks with line numbers. – nhgrif May 12 '15 at 18:31
• @nhgrif Line number request – 200_success May 12 '15 at 18:37
• While we're talking about this, it'd be awesome if our whole design could be renewed and that "beta" label dropped ;) – Simon Forsberg May 12 '15 at 18:38

The asymmetric bottom margin is an unfortunate combination of these CSS rules:

pre { margin-bottom: 1em; }


so it could be fixed with:

blockquote > pre:last-child { margin-bottom: 0; }


with the following result:

I note that the style sheet already has a similar rule for p elements, presumably for the same reason:

blockquote p:last-child { margin-bottom: 0 }


I think it's probably an error to omit the > here, because a p element can match :last-child without being the last child of the blockquote — it might be the last child of some intervening element such as li, in which case we should only suppress the margin if it's the last li in the ol and the last ol in the blockquote. To handle these cases, we need something like:

blockquote > *:last-child,
blockquote > *:last-child > *:last-child,
blockquote > *:last-child > *:last-child > *:last-child {
margin-bottom: 0;
}


Of course this will fail for more deeply nested structures, but I don't know how to specify the property of being the last descendant of an element in CSS.

I have all this in my user style sheet using Stylish.

I talked about the block quotes before, albeit in a different context. I like the way our formatting works in respect to code blocks and block quotes. It's really useful and Stack Overflow now uses a very similar format. (See previous link)

So, sure, it'd be nice to see the margins corrected, but I see little need to change it until 6-8 weeks months from now when we get our own design. Any real "design" to be done with the quote blocks revolves around color, and we can't really discuss that until we know what the site colors will be.

When that time does come, I want to see a high level of contrast between code blocks and quote blocks remain. It's absolutely essential to differentiating between OP's code and our code in answers. What we don't want is something like the old SO formatting.

Old StackOverflow:

Code Review and New Stackoverflow:

• My motivation for mentioning it now is so that the designers can take these kinds of issues into consideration when making our theme. – 200_success May 17 '15 at 15:42
• I figured as much. Doesn't really change my answer. It ain't broke (mostly). Don't fix it (mostly). – RubberDuck May 17 '15 at 15:43