Results 1 to 6 of 6

Thread: Applying Attributes for a child's parent

  1. #1
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Question Applying Attributes for a child's parent

    Sorry if the title isn't that great - I couldn't think of the right wording...

    My problem is that the links on my site have a "border" attribute applied to them, but I don't want this border-bottom to appear below the linked images.

    So what I'm trying to figure out is how to tell it that if there's an "a" tag with an image inside it, the a tag has special attributes applied to it (in my case, no border)

    Is this even possible? If so, can someone please help me out?

    The site where this is is :: http://x96wd.tech.officelive.com/

    Please don't give me feedback on the design - I'm working on it!

    Thanks in advance.
    Last edited by X96 Web Design; 02-28-2009 at 07:03 PM. Reason: resolved
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    I'm going to suppose you mean the "red menu" here : http://x96wd.tech.officelive.com/red-menu.html?

    Anyway, I think what you want to do is add "border:none" to #menu ul li a:

    Code:
    #menu ul li a {
      color:#FFF;
      text-decoration:none;
      padding:15px;
      margin:0;
      background:transparent;
      margin-left:-4px;
      border:none;
    }
    This will get rid of any borders for any links on the menu, you could always move it to #menu ul li - if you add an item without a link in the future.

    Hope that helps.

  3. #3
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    Actually, it was for the back button (which I haven't added to that page... I'll get right on that...).

    But thanks for pointing out the menu, I forgot about that...

    EDIT: I just added the Back button... It's at the very top above the Heading.
    Last edited by X96 Web Design; 02-28-2009 at 05:21 AM. Reason: update
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  4. #4
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Unfortunately there is no way to target the parent of an element with CSS, not even with CSS3. You have two options (that I can think of). The simplest one would be to just give the anchor tags that you want to target (i.e. the ones containing images) a class value, e.g.:
    HTML Code:
    <a href="/" class="imageanchor"><img src="back.png></a>
    Then use CSS to remove the border.

    Another option is to use JavaScript to target the anchor tags that have image tags as child elements (jQuery would be easy to use for this). This is of course more complicated and will not work if JavaScript is turned off. I would only recommend this if you for some reason cannot ad a class value to the anchor tags.

    Good luck!

  5. #5
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    I just updated the links so they just have a underline attribute, no borders any more...

    Thanks anyway, though!
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  6. #6
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You're welcome, glad to help!
    You can go to your first post in this thread, click then click Go Advanced and add the Resolved prefix to the thread title.
    This will let other users know the problem has been solved.

    Good luck with your site!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •