G
G
GreenDad2020-01-11 22:52:40
Pug
GreenDad, 2020-01-11 22:52:40

Why does Pug convert a div to a span if I add it inside a link?

Good afternoon, please tell me how to solve this problem?
This is

+b.A.test(href="#")
    +e.content

Converts to:
<a href="#" class="test">
    <span class="content"></span>
</a>

How to fix it ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Morev, 2020-01-11
@SeaInside

Pug prevents you from making the mistake of not nesting a block-level element within an inline element.
You need behavior like a block element inside an inline element - set its type through styles.

<a href="/" class="link">
  <span>Link text</span>
</a>

.link span {
  display: block;
}

How old I am... Suddenly, HTML5 doesn't forbid this and it's not considered a bug. It was not possible before.
But IMHO, it's like with the definition of the gender of the word "coffee" - by today's standards it is possible both in male and in the middle, but nevertheless, in a decent society, "coffee" in the middle gender is difficult to hear.
New answer to the question (bemto allows you to do this):
+b.A.test(href="#")
  +e.DIV.content

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question