Rosmarine Popcorn
Rosmarine Popcorn

Reputation: 10967

Paragraph inside Anchor cannot be formated

while working i messed HTML because i did not knew that <p> tag within <a> tag does not get formated .

Like if i had :

<a>
 <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, </p>
</a>

where <a> parent width is 200px; text goes through 200px; instead of putting New Lines to fit the text inside .

Upvotes: 0

Views: 1438

Answers (3)

Oleg
Oleg

Reputation: 24988

Your markup is just missing the compulsory anchor href attribute. The following would render properly:

<a href="#">
  <p>Lorem Ipsum is simply dummy text... ever since the 1500s, </p>
</a>

Check it out

Upvotes: 0

Different55
Different55

Reputation: 597

Adding the display: block; to the a element fixes it. The a tag is an inline element by default. It was not meant to hold other elements and so the width property does not affect it. Using CSS to make it display like a block element should make properties like width work correctly. I've got a working demo on jsfiddle here.

Upvotes: 0

Elen
Elen

Reputation: 2343

try to make

a {
display: block;
}

Upvotes: 3

Related Questions