Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJi Jiang
2,505 Pointsword-wrap property doesn't work if I select anchor element
I am trying word-wrap property on the following HTML tags: <p class="word-wrap"><a href="#">a very very long link</a></p> In the CSS I have to select the .word-wrap class to wrap the link ( .word-wrap{word-wrap:break-word;} ).
If I select the anchor element like below, it doesn't wrap the link. a {word-wrap:break-word;} Can anyone tell me why? Thanks.
Ji Jiang
2,505 PointsThanks for replying. Now I know what the problem is. I was using Eclipse to test my code and it doesn't work in eclipse. But if I test it on treehouse workspace it is working now. Thank you!
2 Answers
Dai Phong
20,395 Pointsapply word-wrap property to the container of elements which you want to wrap. ".word-wrap" is a container of "a" element so apply it to ".word-wrap" instead of "a" element.
Ji Jiang
2,505 PointsThank you! Pls see above comment.
Jason Anello
Courses Plus Student 94,610 PointsHi Ji,
You should get the same result when applying directly to the link.
The word-wrap property is inherited so when you apply it to .word-wrap
the link is going to inherit that value. Applying it directly to the link should have the same result.
Ji Jiang
2,505 PointsThank you! Pls see above comment.
Sreng Hong
15,083 PointsSreng Hong
15,083 PointsHi Ji, I think you can use both selector (
.word-wrap
anda
) to make the link break. I've tested already. You can check your code again. If it's still problem, you can post your code here and I'll try to help again. Thanks