Results 1 to 5 of 5

Thread: padding not getting applied to <a> link

  1. #1
    Join Date
    Nov 2011
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default padding not getting applied to <a> link

    Hi

    I want to apply padding to CATEGORY LINK which is inside <li>

    Only left padding is getting applied

    but Top and Bottom padding is not getting applied

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    #leftnav li{list-style:none; background-color:#4b5913; padding:0px; color:#FFFFFF; margin-bottom:2px}
    #leftnav ul li{background-color:#FFFFFF; color:#333333; padding:7px; border-bottom:1px dashed #999999}
    #leftnav li a{padding:40em 0 40px 40px; text-decoration:none; color:#FFFFFF;}
    </style>
    </head>
    
    <body>
    <ul id="leftnav">
    			<li><a href="">CATEGORY</a>
    			<ul>
    				<li>sublink</li>
    				<li>sublink</li>
    				<li>sublink</li>
    			</ul>
    			
    			</li>
    			
    			<li><a href="">CATEGORY</a></li>
    			<li><a href="">CATEGORY</a></li>
    		</ul>
    </body>
    </html>
    thanks
    vineet

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    <a> is an inline element so you need to change the display property to display:block;
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Nov 2011
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    <a> is an inline element so you need to change the display property to display:block;
    Thanks Beverleyh
    All working fine now

    vineet

  4. #4
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    Did you really mean to do this:

    #leftnav li{list-style:none; .....

    The list-style property is intended to be applied to the parent list (<ul> or <ol>), not the list elements themselves. Click on this link for more information.

  5. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Quote Originally Posted by styxlawyer View Post
    Did you really mean to do this:

    #leftnav li{list-style:none; .....

    The list-style property is intended to be applied to the parent list (<ul> or <ol>), not the list elements themselves. Click on this link for more information.
    I think it's important to clarify that while applying list-style to the parent ul/ol is preferred/recommended (due to more predictable inheritance) there is nothing wrong with applying it to li elements either. Both ways are perfectly valid. The specs only state that it should be applied to the li with care so that the choice of (child/descendant) selector does not produce undesirable results.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. padding:initial vs. padding:0
    By Rain Lover in forum CSS
    Replies: 1
    Last Post: 07-17-2014, 11:07 PM
  2. Padding issue on link list.
    By alexwdesign in forum CSS
    Replies: 1
    Last Post: 08-27-2008, 01:35 AM
  3. Replies: 0
    Last Post: 08-31-2007, 02:27 PM
  4. iframes applied to my site...Plz help!
    By Lattman in forum HTML
    Replies: 2
    Last Post: 03-25-2006, 07:23 AM
  5. Replies: 4
    Last Post: 10-28-2005, 07:05 PM

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
  •