We have in Seven's page.html.twig file:

{% if messages %}
  <div id="console" class="clearfix">{{ messages }}</div>
{% endif %}

and in Seven's style.css:

/**
 * Console.
 */
#console {
  margin: 9px 0 10px;
}

Using ID selectors as styling hooks are bad practice according to our CSS coding standards. We should use classes.

Anyway I do not know why we use a wrapper element to add some margin around messages. If there is no other goal of this wrapper than providing the margin than we may remove it and add the margin to messages instead(?)

(See this comment #2017257-50: Create generic layout classes also.)

Comments

lewisnyman’s picture

I think we should remove it. I'm not sure what it's purpose is.

gábor hojtsy’s picture

Well, the only purpose as is displayed is that it contains the messages. It clears floats and puts a margin around messages in general. If you put margins on messages one by one, then they will be set apart from each other. If you put a margin around the first message appearing on the page and the last, then when multiple message areas are used, such as with #2318381: Message not styled properly on interface translation page , then the margin will not appear properly. So thats why.

lewisnyman’s picture

We don't have anything floating within messages anymore, but let's assume we need to keep it it for vertical spacing. The correct class inline with our CSS standards would be .messages__container

lewisnyman’s picture

Issue tags: +frontend, +CSS, +dreammarkup
gábor hojtsy’s picture

lewisnyman’s picture

Title: Swich to a class or remove #console » Replace #console with .messages__container
rteijeiro’s picture

Issue tags: +CSS novice, +Novice

Let's tag it with novice tags.

csakiistvan’s picture

Status: Active » Needs review
StatusFileSize
new929 bytes

Status: Needs review » Needs work

The last submitted patch, 8: 2321121_replace_id_with_class_8.patch, failed testing.

Status: Needs work » Needs review
gábor hojtsy’s picture

Status: Needs review » Needs work
+++ b/core/themes/seven/css/style.css
@@ -126,7 +126,7 @@ ul.menu li.expanded {
 /**
  * Console.
  */
-#console {
+.messages__container {

IMHO we should update the comment as well. Since we did not know what console was for in the first place, it is not disambiguating to say on a comment that this is the "Console". Probably based on the class names, there is no need for a comment? It looks pretty trivially the message container :)

thamas’s picture

Switching to class from ID is a good idea but I still do not understand why we need this wrapper div. Lewis stated that we do not need to clear any floats anymore. So the wrapper only adds margin "around" the top and bottom of message or messages. But to get this result we do no need a wrapper! We can define this margins in messages class.

I do not understand the answer in #2 about "setting apart messages". Vertical margins are collapsed by browsers and there is also a

.messages + .messages {
  margin-top: 1.538em;
}

rule in system.theme.css which sets the distance between messages.

Otherwise the comment should not say that "this is the messages container" but the purpose of this container – and that is the answer to my question(?).

thamas’s picture

By the way we have some other id-s in page.html.twig such as #branding, #content, #help, #footer and some styling applied in style.css to #barnding and #help. Maybe we should change them from id to class too. (Have anyone created an issue about them yet?)

gábor hojtsy’s picture

Ok how would you define those margins on the messages?

thamas’s picture

Issue summary: View changes
csakiistvan’s picture

#14 we add this margin to .messages class

Edit: but only in seven theme, i think its better

thamas’s picture

Simply adding margin: 9px 0px 10px; to the .messages class (and disable the margin defined by #console) seems working to me.

csakiistvan’s picture

Status: Needs work » Needs review
StatusFileSize
new889 bytes
lewisnyman’s picture

Issue tags: +needs screenshots

Great! Happy to RTBC once we get some before/after screenshots to ensure it's identical.

lewisnyman’s picture

Title: Replace #console with .messages__container » Remove #console
csakiistvan’s picture

StatusFileSize
new139.02 KB
new162.11 KB
thamas’s picture

Hm. What if we add the margin in system.theme.css instead of style.css of Seven?

lewisnyman’s picture

How does Bartik/Stark handle spacing now? I'd usually steer clear of adding more CSS for all themes but as messages are usually fully styled on every theme maybe it makes sense?

lewisnyman’s picture

This issue died a little. Let's just stick with Seven for now. No reason to open the scope up here.

thamas’s picture

@jamesquinton made the CSS change in #2213583-84: Misaligned Icons in Drupal 8.x - it needs review. (And the twig file change should be done too.)

gábor hojtsy’s picture

Status: Needs review » Closed (duplicate)
csakiistvan’s picture

yeah