alt and title when using div

Discussion in 'HTML & Website Design' started by scubah, Jun 8, 2008.

  1. #1
    sorry ladies and gents this maybe a newbie question but i googled and couldnt find an answer....

    i want to optimize my alt and title tags for images, in my index.php i have something like;

    <div id="logo" alt="logo" Title="here is our logo">&#160;</div>[CODE]
    
    and then in the css file i have the url for the image that relates to id="logo"
    
    when i look in the firefox with images turned off I get the title when i hover where the image should be but no alt text?
    
    am i doing something wrong?
    Code (markup):

     
    scubah, Jun 8, 2008 IP
  2. mds

    mds Active Member

    Messages:
    256
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #2
     
    mds, Jun 8, 2008 IP
  3. scubah

    scubah Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    sorry i dont understand make the code?
    <div id="logo" alt='logo' Title='here is our logo'> </div>[code]
    
    replacing " with ' for alt and title?
    Code (markup):
     
    scubah, Jun 8, 2008 IP
  4. twistedspikes

    twistedspikes Notable Member

    Messages:
    5,694
    Likes Received:
    293
    Best Answers:
    0
    Trophy Points:
    280
    #4
    alt's don't go in divs...:rolleyes: use them for images and other media
     
    twistedspikes, Jun 8, 2008 IP
  5. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #5
    Alt is Alternative

    Say, the image path is broken or will not load, it will load the alernative

    so if i did

    <img src="cow.png" alt="COW!!!"/> and it cannot find the image, it will display the text "COW!!!".

    this is not needed in divs because they will always load.

    You just need this for externally loaded media such as videos images etc.
     
    crath, Jun 8, 2008 IP
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You need to use the IMG element for the alt="" attribute to work. Since you're focusing on the logo, use this markup:

    
    <div id="header">
    	<img src="/images/logo.png" width="200" height="80" alt="Web Site Name" title="">
    </div>
    
    Code (markup):
    A few things: the file extension can be either a .gif .jpg or .png - the width and height values I gave are placeholders (use whatever the size of your logo is) - "Web Site Name" is just a placeholder for the name of the site - title="" is needed to fix a bug in Internet Explorer.
     
    Dan Schulz, Jun 8, 2008 IP
  7. scubah

    scubah Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    so basically i shouldnt bother to put the images in the css file just put the code like dan suggest above then i can include the alt and title etc.

    can i still leave the margin and hieght,padding etc in the css file but just delete the background url and put that in the html?

    thanks for your great help!!!!!!!
     
    scubah, Jun 9, 2008 IP
  8. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Oh no, if the images are not content (if they are decoration) they should be in the background with CSS! It's just that, Dan was giving an example of using alt text, which is text that must be added to any images which are in the HTML (with the <img src="..."> tag).

    Title is for when you need to explain something a little, usually a link (because title shows on mousehover) (you can put it on other things like an image, but it does not show unless hovered over!). Like, if you do something like this:

    Click here for awesome deals.

    You should have a title on the link which says "Find deals here at Joe's Fishing and Tackle site" or something.. tell people where they are clicking (of course, "click here" is bad form anyway, but I've had to use it myself when told to).
     
    Stomme poes, Jun 9, 2008 IP