/    Sign up×
Community /Pin to ProfileBookmark

Weird Problem with Alt attribute in Images

Hello.
I’m working on a site that I did not design or code. I just took over to finish some small things here and there and plan on maintaining the site.

I’ll go ahead and state my problem up here in case you already now the answer. If you want more info on the situation then read on. I restate my problem further down.

“Here’s my problem. When images are disabled my Alt attribute is falling below where the images are.”

The site is designed with a footer. Which contains a Bottom Horizontal Nav Bar. The properties are below

[code]
#footer {
background-color: #b84;
background-image: url(‘images/desert-bottom.jpg’);

bottom: 0px;
height: 64px;
position: absolute;
width: 100%;
}
#footerlinks {
color: #000;
list-style-type: none;
margin: 0;
padding: 7px 0 0 0;

font-size: 1.3em;
text-align: center;
white-space: nowrap;
}
#footerlinks li {
display: inline;
padding: 0 1em 0 1em;
}
[/code]

The full footer image is massive. And is designed to be revealed as your screen size increases. I’m pretty sure thats why he used display: inline. Rather then just floating left. So he could then use text-align: center to always keep the links centered horizontally no matter how big your screen gets. I only mention this because my problem is fixed by taking out inline and just floating the links left. But I’d rather not do that.

Now we’ve decided to make a second smaller row for less important links. So I just made a new ul and kept most of the same css properties. And just made the images in the (x)html smaller.

Here’s my problem. When images are disabled, my Alt attribute is falling below where the images are. But only in the Main Footer links. It does not happen in the sub links below them that is contained in the same <div> (footer). The only difference is their part of a different <ul> and id to go along with that <ul>. Also this does not happen on the original site. Which can be found here. [url]http://apache-moon.net/realsite[/url]
Turn off images and you’ll see that “News” “Story” etc. display their alt attributes and don’t seem to move. The CSS for that site’s footer is here.

[code]
#footer {
background-color: #b84;
background-image: url(‘images/desert-bottom.jpg’);

bottom: 0px;
height: 64px;
position: absolute;
width: 100%;
}
#footerlinks {
color: #000;
list-style-type: none;
margin: 0;
padding: 20px 0 0 0;

font-size: 1.3em;
text-align: center;
white-space: nowrap;
}
#footerlinks li {
display: inline;
padding: 0 0.5em 0 0.5em;
}
[/code]

As you can see very little difference. Also I’ve tried replacing values across the two style sheets. Nothing seems to work. So I was thinking it might be an inherited value from another CSS property somewhere else in the style sheet. I’ve looked over it several times. But if you want you could give it a look. The entire and only style sheet for the page is here.

[code=html]
/* — Comment — */

html, body {
background-color: #000;
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
font-family: Georgia, serif;
}
a {
color: #750;
}
a:active {
color: #a80;
}
a:hover {
color:#a80;
}
a:visited {
color: #750;
}
a img {
border: none;
}
img {
margin: 0;
padding: 0;
}

/* — Content Window — */

#storythumbs {
margin: 3em 0 0 0;
padding: 0 0 0 0;
}
.biothumb {
float: left;
margin: 0 2.5em 2em 0;
text-indent: 0.4em;
}
.biothumb a img {
vertical-align: middle;
margin: 0 0.5em 0 0;
}
.closebutton {
float: right;
}
.backbutton {
float: right;
padding: 0 0.5em 0;
}
.headerimage {
background: #fff;
line-height: 0;
margin-bottom: 1em;
margin-top: 3em;
width: 100%;
}
.hollow {
color: #ccc;
background-image: url(‘images/hollow.png’);

width: 70%;

top: 30%;
bottom: 100px;
left: 15%;
}
.paper {
background-color: #ffb;
background-image: url(‘images/paper.jpg’);

width: 70%;

top: 20%;
bottom: 100px;
left: 15%;
}
.window {
display: none;
overflow: auto;
padding: 1em;

position: absolute;

}
.window h3 {
margin-top: 0;
}
.first {
margin-top: 3em;
}

#window_news {
display: block;
}
.paperheader {
position: fixed;
top: 20%;
left: 15%;
right: 14%;
bottom: 72%;
padding: 0.5em 0 0 1em;
margin: 0;

background-color: #b84;
background-image: url(‘images/paper.jpg’);
}
.paper p {
text-align: justify;
}
/* — Background and Footer — */

#horizon {
background-color: #000;
background-image: url(‘images/desert-top.jpg’);

bottom: 64px;
height: 452px;
position: absolute;
width: 100%;
}
#footer {
background-color: #b84;
background-image: url(‘images/desert-bottom.jpg’);

bottom: 0px;
height: 64px;
position: absolute;
width: 100%;
}
#footerlinks {
color: #000;
list-style-type: none;
margin: 0;
padding: 7px 0 0 0;

font-size: 1.3em;
text-align: center;
white-space: nowrap;
}
#footerlinks li {
display: inline;
padding: 0 1em 0 1em;
}
#minilinks {
color: #000;
list-style-type: none;
margin: 0;
padding: 0 0 0 0;
text-align: center;
white-space: nowrap;
}
#minilinks li {
display: inline;
padding: 0 0.5em 0 0.5em;
}
#moon {
bottom: 60%;
left: 50%;
position: absolute;
}
#smalllogo {
bottom: 16px;
left: 16px;
position: absolute;
}
#epiclogo {
bottom:5px;
right: 3px;
position: absolute;
}
[/code]

I attached a screen shot of the page so you can see what the links look like.
“News” “Store” and “Characters” have their images turned on. (Characters Alt attribute does not move from where it’s image sits and is working correctly) “About” and “Media” have their images turned off. And as you can see the Alt text is displayed. But for some reason it falls below where their images were being displayed.

Thanks for any help you guys can give.

[upl-file uuid=31edb893-33f5-43a6-9920-8935c2afe136 size=80kB]Screenshot.jpg[/upl-file]

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@KDLAMay 15.2008 — Check out these errors: http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fapache-moon.net%2Frealsite%23news

Also, I think you're misunderstanding what an alt attribute is. "Alt" or "alternative text" is the descriptive text used for screen readers. When images are downloaded properly, IE improperly displays alt information like a tooltip; FX treats this correctly by ignoring it. When an image fails to download (the dreaded little square with the "x"), the alt text is displayed to let you know what you're missing.

What you're working with is "image replacement," where text is rendered invisible through CSS and rendered visible if CSS is disabled.

In this case, the problem comes for an overusage of absolute positioning. You can tell positioning is used from simply looking at the HTML -- the links are not positioned together, but strung out among the other blocks of text.

I suggest that you recode the footer links to be in one <ul>, with display inline (or with <li> floated left), and get rid of the positioning. That should solve most of your problems.

KDLA
Copy linkTweet thisAlerts:
@nodestarauthorMay 15.2008 — Check out these errors: http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fapache-moon.net%2Frealsite%23news

Also, I think you're misunderstanding what an alt attribute is. "Alt" or "alternative text" is the descriptive text used for screen readers. When images are downloaded properly, IE improperly displays alt information like a tooltip; FX treats this correctly by ignoring it. When an image fails to download (the dreaded little square with the "x"), the alt text is displayed to let you know what you're missing.

What you're working with is "image replacement," where text is rendered invisible through CSS and rendered visible if CSS is disabled.

In this case, the problem comes for an overusage of absolute positioning. You can tell positioning is used from simply looking at the HTML -- the links are not positioned together, but strung out among the other blocks of text.

I suggest that you recode the footer links to be in one <ul>, with display inline (or with <li> floated left), and get rid of the positioning. That should solve most of your problems.

KDLA[/QUOTE]




All those errors are from the site thats online. My site validates with both CSS and (X)HTML 1.0 strict. But either way all those errors have to do with comments. The original coder of the site used <!-------- ----------->

Rather than <!-- --> I've since fixed that. And it shouldn't affect my problem wither way.

I understand what the "alt" does. I know it's a replacement for the image when either it can't be downloaded. Or people with bad connections, or any other reason have images turned off. What I was doing was looking at my site with images turned off to make sure everything was well and in order for those people that would be viewing the site without images. And thats when I saw that instead of my alt text directly replacing my image. It was falling down below it. Causing a cramped affect of my links.

If were thinking of the same image replacement then yes, in a since thats what I'm doing. But not exactly. In the image replacement I'm thinking of you use a background image that looks like the text you would normally display.

So the word Title. Gets a background image of TITLE!. Then you use CSS to give it a negative index or just hide it all together. When CSS is turned off the background image goes away and the hidden text is revealed.

That's not what is going on here. Not on the technical level anyway. I'm just using an image that looks like a word. As the image for a Link. There is no text involved. If CSS is turned off the image link will remain and function. When images are turned off the failsafe is just the alt text. Which becomes the link.

The only instance of absolute positioning that affects the footer links is in the footer div.

So..

<div id="footer"> is absolutely positioned.

<ul id="footerlinks"> has no set positioning. It just falls in the footer div naturally. The only thing it gains is

#footerlinks {

color: #000;

list-style-type: none;

margin: 0;

padding: 6px 0 0 0;

font-size: 1.3em;
text-align: center;
white-space: nowrap;

}

Likewise the li itself is not given any position attribute.

It only gains

#footerlinks li {

display: inline;

padding: 0 1.7em 0 1.7em;

}

I don't want the Links to be in one <ul>. For the Site the owners requested two. A main Links <li> and then a sublinks <li> below them. Made slightly smaller. I don't think it should cause any problem.

I don't understand what you mean by

the links are not positioned together, but strung out among the other blocks of text.[/QUOTE]

There are two unordered (<ul>) Lists. They both contain their appropriate List items(<li>). They are in turned contained by a single <div>. Both Unordered Lists are display: inline; They do that instead of floating to gain the advantage of being able to use the text-align: center; So the links will always be centered as the page expands.

Also as I said in my original post I've tried commenting out the CSS and HTML for the second <ul> And the first <ul> still be haves the same way.

My Browser is Firefox 2.something. And I'm going to have FF 3.5 Beta if I ever get around to upgrading to Hardy Heron. So it's not a IE problem of any sorts.

Thanks for any more help you can provide.
Copy linkTweet thisAlerts:
@CentauriMay 16.2008 — Are there any styles attached to the #footerlinks a ?? - if the size of the <a> is only set by the size of the image (which I assume is in the html where it doesn't really belong), then the <a> will collapse to text height and width if the image is not available. If the <a>s are sized in the css to suit, then they will not change if the image is not available.
Copy linkTweet thisAlerts:
@nodestarauthorMay 16.2008 — There are no styles attached to the [CODE]#footerlinks a[/CODE] that I'm aware of. I'm no expert on CSS or HTML but the reason I put the dimensions of the img in the HTML is so when the page loads the browser will make space for the image before it begins to load(after the text is loaded). This way the text won't fill in and then expand back out to make room for the images. It's just been explained to me that way. So thats what I do.

I added height and width to the a like so.

#footerlinks li a {

height: 28px;

width: 55px;

}

It didn't help. The problem isn't that the images box is collapsing. But the box around the alt text is dropping down below where the image box was.

Not sure if I incorporated that width and height correctly. Let me know please. Thanks for the help.
Copy linkTweet thisAlerts:
@CentauriMay 16.2008 — I really think we need to see this live, at a tempory url if you like. It could even come down to an inhereted style from somewhere else that we cannot see with code snippets.
Copy linkTweet thisAlerts:
@nodestarauthorMay 16.2008 — I can't get the updated site on the net right now. You can view the none updated version here. http://apache-moon.net/realsite

Here is the whole style sheet for the updated site.

[CODE]
/* --- Comment --- */

html, body {
background-color: #000;
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
body {
font-family: Georgia, serif;
}
a {
color: #750;
}
a:active {
color: #a80;
}
a:hover {
color:#a80;
}
a:visited {
color: #750;
}
a img {
border: none;
padding: 0;
margin: 0;
}
img {
margin: 0;
padding: 0;
}

/* --- Content Window --- */

#storythumbs {
margin: 3em 0 0 0;
padding: 0 0 0 0;
}
.biothumb {
float: left;
margin: 0 2.5em 2em 0;
text-indent: 0.4em;
}
.biothumb a img {
vertical-align: middle;
margin: 0 0.5em 0 0;
}
.closebutton {
float: right;
}
.backbutton {
float: right;
padding: 0 0.5em 0;
}
.headerimage {
background: #fff;
line-height: 0;
margin-bottom: 1em;
margin-top: 3em;
width: 100%;
}
.hollow {
color: #ccc;
background-image: url('images/hollow.png');

width: 70%;

top: 30%;
bottom: 100px;
left: 15%;
}
.paper {
background-color: #ffb;
background-image: url('images/paper.jpg');

width: 70%;

top: 20%;
bottom: 100px;
left: 15%;
}
.window {
display: none;
overflow: auto;
padding: 1em;

position: absolute;

}
.window h3 {
margin-top: 0;
}
.first {
margin-top: 3em;
}

#window_news {
display: block;
}
.paperheader {
position: fixed;
top: 20%;
left: 15%;
right: 14%;
bottom: 72%;
padding: 0.5em 0 0 1em;
margin: 0;

background-color: #b84;
background-image: url('images/paper.jpg');
}
.paper p {
text-align: justify;
}
/* --- Background and Footer --- */

#horizon {
background-color: #000;
background-image: url('images/desert-top.jpg');

bottom: 64px;
height: 452px;
position: absolute;
width: 100%;
}
#footer {
background-color: #b84;
background-image: url('images/desert-bottom.jpg');

bottom: 0px;
height: 64px;
position: absolute;
width: 100%;
}
#footerlinks {
color: #000;
list-style-type: none;
margin: 0;
padding: 6px 0 0 0;

font-size: 1.3em;
text-align: center;
white-space: nowrap;
}
#footerlinks li {
display: inline;
padding: 0 1.7em 0 1.7em;
}
#footerlinks li a {
height: 28px;
width: 55px;
}
#minilinks {
color: #000;
list-style-type: none;
margin: 0;
padding: 0 0 0 0;
text-align: center;
white-space: nowrap;
}
#minilinks li {
display: inline;
padding: 0 1.5em 0 1.5em;
}
#moon {
bottom: 60%;
left: 50%;
position: absolute;
}
#smalllogo {
bottom: 16px;
left: 16px;
position: absolute;
}
#epiclogo {
bottom:5px;
right: 3px;
position: absolute;
}
[/CODE]



And the HTML that makes up the Main Horizontal Nav.

[CODE]
<div id="footer">
<ul id="footerlinks">
<li><a href="#news" onclick="showWindow('news');"><img src="images/news.gif" width="56" height="28" alt="News" title="" /></a></li>
<li><a href="#about" onclick="showWindow('about');"><img src="images/about.gif" width="55" height="28" alt="About" title="" /></a></li>
<li><a href="#media" onclick="showWindow('media');"><img src="images/media.gif" width="57" height="28" alt="Media" title="" /></a></li>
<li><a href="#store" onclick="showWindow('store');"><img src="images/store.gif" width="55" height="28" alt="Store" title="" /></a></li>
</ul>

<ul id="minilinks">
<li><a href="#characters" onclick="showWindow('characters');"><img src="images/characters.gif" width="85" height="20" alt="Characters" title="" /></a></li>
<li><a href="#timeline" onclick="showWindow('timeline');"><img src="images/timeline.gif" width="55" height="20" alt="Timeline" title="" /></a></li>
<li><a href="#filler" onclick="showWindow('filler');"><img src="images/filler.gif" width="55" height="20" alt="Filler" title="" /></a></li>
</ul>
</div>[/CODE]
×

Success!

Help @nodestar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...