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!
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 trial
Pol Ribas Pibernat8,952 Points
A link inside another link
I would like to make a div (post) clickable, and inside it, to have the post name and its category. I would like to be able to click the category also, but when I put the category's link inside the clickable div, the div isn't a link anymore.
Here's the code:
<a href="<?php echo $item['post_name']; ?>" class="news-ticker-link"> <div class="news-ticker-post">
<div class="news-ticker-post-category"> <a href="<?php echo $item['post_cat_slug']; ?>"><?php echo $item['post_cat'];?></a> </div> <div class="news-ticker-post-title"> <?php echo $item['post_title']; ?> </div> <span style="display:inline-block;"> · <span> </div> </a>
How can I do it in order to have 2 links inside a div?
Daan Schouten14,454 Points
I'd say that what you are trying to do simply isn't possible, and even if it were, it really isn't desirable. For example, how does a user know which link he clicks on?
You could put two divs or a's above each other, or next to each other. Not sure this is the solution you wanted, but it is more functional than what you are trying to achieve.