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 .

有帮助吗?

解决方案

try to make

a {
display: block;
}

其他提示

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.

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top