wich is the best practice to insert a button in a html with background image

Posted on 2012-08-22
Last Modified: 2012-10-01

i have a html file
i'm  making an html site.

could you help me to select the best practice to insert  buttons  faceboook, twiiter, and menu's options

thanks a lot
Question by:tenriquez199
    LVL 8

    Assisted Solution

    First of all, your html link doesn't work.

    OK, it's really simple.  I'll show you the basic code.  Since I can't currently see your html I won't be able to format it the way you want, but here is the basics:

    <a href="inicio.htm"><img src="yourimagedirectory/iniciobutton.jpg"></a>
    <a href="proyecto.htm"><img src="yourimagedirectory/proyectobutton.jpg"></a>
    <a href="contacto.htm"><img src="yourimagedirectory/contactobutton.jpg"></a>

    Open in new window

    LVL 18

    Assisted Solution

    For me the best practice is to create the link in HTML (<a href ="link.html">) then style the link so it looks like a button in CSS.

    For example, the html could be:
    <div class="menu">
        <ul class="nav">
          <li><a href="index.html">Home</a></li>
          <li><a href="about.html">About Us</a></li>

    Then the CSS could be:
    .menu {
          float: left;
          width: 20%;
          background-color: #FFF;
          padding-right: 10px;

    ul.nav li {
          border-bottom: 1px solid #666;
          color: #FFF;
    ul.nav a, ul.nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */
          padding: 5px 5px 5px 15px;
          display: block; /* this gives the link block properties causing it to fill the whole LI containing it. This causes the entire area to react to a mouse click. */
          text-decoration: none;
          color: #000;
          background-color: #FFF;
    ul.nav a:hover, ul.nav a:active, ul.nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */
          color: #FFF;
          background-color: #900;

    For the facebook and other social media icons, you can use ( It has multiple styles and is easy to add to your code.
    LVL 1

    Author Comment

    hi Barry62


    the link is

    thanks a lot
    LVL 1

    Author Comment

    hi Rartemass

    thanks a lot

    i did a test with you recommend to me, but that menu is shoed at bottom

    could you help me to set it within image background?

    thanks a lot
    LVL 18

    Accepted Solution

    The issue is that you have the image specified and the flow of the page continues beyond that. You have several options. I will list them in the preferred order.

    1) If you intend the image to be the background, remove the <img src=...> line and style the body to have it as the background.

    So the CSS would be

    body {

    2) You can use z-index to position them. Z-index only works on elements that have the position property in CSS. This explains the process:

    If after reading this you need some assistance, please ask.

    3) Reposition the image in your html so it is after the menu. This however will result in the menu being above the image. If you want them overlapping you need one of the above options.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now