Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7711263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:19:52+00:00 2026-06-01T01:19:52+00:00

A usual way to put, for example a menu tab with background is as

  • 0

A usual way to put, for example a menu tab with background is as follows:

<ul id="main-nav">
   <li><a href="url1.php">Menu 1</a></li>
   <li><a href="url2.php">Menu 2</a></li>
</ul>

Then with css

#main-nav li { float:left; margin-right:10px; list-style-type:none; }
#main-nav li a { display:block; padding:10px }

All is fine and dandy, but then I decided to use image for each <li>, supposing the image dimensions is 200x200px, so I add the following:

#main-nav li a { 
   display:block; padding:10px;
   background:url(/img/tab-bg.png) transparent no-repeat; 
   width:200px; height:200px;
}

But since the link inside has a padding of 10px, I need to substract 20px from width and height of the anchor or else it will cause li to overflow. Is this the correct way of doing things like this? I imagine if later down the road I need to change the image with a bigger dimension one, I will always need to remember to substract the actual image size by 2 times the padding, is there a simpler way of achieving this (without having to substract everytime to cater for the new background image size)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:19:53+00:00Added an answer on June 1, 2026 at 1:19 am

    Use box-sizing: border-box. Then the width will include padding and border, rather than excluding it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The usual way to resolve lnk involve using WShell.WshShortcut or IShellLink that way :
The usual way to assign color box functionality on a link is like this:
What is the most usual way to develop views in asp.net mvc? Should I
This is my usual way to debug javascript. Include alert(0); to break the flow
I have a shop system that integrates PayPal in the usual way, i.e. the
I have a nib that I load the usual way [NSBundle loadNibNamed:@AuthorizationWindow owner:self]; and
As I remember and checked, the usual way for traversing a tree or crawling
I want to comment several lines in my .vimrc, the usual way I do
What is the usual/clearest way to write this in Python? value, _ = func_returning_a_tuple()
The usual way to use Qt widgets from Python seems to be to subclass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.