Ticket #139 (closed enhancement: invalid)

Opened 4 years ago

Last modified 4 years ago

AlternateText should be rendered as "title" instead of "alt"

Reported by: kmeirlaen Owned by: somebody
Priority: minor Milestone: 1.1
Component: QForms Version:
Keywords: Cc:

Description

QImageButton is using AlternateText? to render an "alt" tag when rendering the Image.
The "alt" tag is however not supported in FireFox?. Instead of Alt, the "title" should be rendered, which is supported by both browsers:

--- original code ---

if ($this->strAlternateText)

$strToReturn .= sprintf('alt="%s" ', $this->strAlternateText);

--- end ---

--- suggested code ---

if ($this->strAlternateText)

$strToReturn .= sprintf('title="%s" ', $this->strAlternateText);

--- end ---

There may be MORE controls using the alt attribute for images. If somebody could go through the code and search/replace the occurences?

Change History

  Changed 4 years ago by VexedPanda

alt and title serve two different purposes.
"alternate text" is what is displayed when the image can't be, and as such corresponds to the "alt" attribute.
"title" controls what the image is called, and is most often rendered as a tooltip for the image in question.

If Firefox doesn't support "alt", then you will probably want to set both AlternateText? as well as setting a title.

  Changed 4 years ago by VexedPanda

  • status changed from new to closed
  • resolution set to invalid

  Changed 4 years ago by VexedPanda

To emphasize, the alt attribute is a REQUIRED attribute for img tags. I find it hard to believe FF doesn't treat it correctly.

  Changed 4 years ago by marcosdsanchez

  Changed 4 years ago by basilieus

Agree with Vex, ALT tags are required for all images in W3C standards.

follow-up: ↓ 8   Changed 4 years ago by kmeirlaen

@all: i think FF does support the ALT tag, but only when the image is not displayed eg when the browser is not loading the images, the alt text is displayed instead. (not verified).
IE renders the alt tag in a small popup/floating box.
This is what I wanted, but apperantly, there the suggested approach (changing alt) is not the way. Instead, we may want to add a strTitleText member and render it when it is filled as title="thetext".

in reply to: ↑ 7   Changed 4 years ago by marcosdsanchez

Replying to kmeirlaen:

@all: i think FF does support the ALT tag, but only when the image is not displayed eg when the browser is not loading the images, the alt text is displayed instead. (not verified). IE renders the alt tag in a small popup/floating box. This is what I wanted, but apperantly, there the suggested approach (changing alt) is not the way. Instead, we may want to add a strTitleText member and render it when it is filled as title="thetext".

I agree with you on that approach

  Changed 4 years ago by kmeirlaen

@all: if alt tags are required, then QCubed renders them incorrectly:

if ($this->strAlternateText)
    $strToReturn .= sprintf('alt="%s" ', $this->strAlternateText);

the if statement should be omitted, as alt tag should always be rendered, even when it is empty?

  Changed 4 years ago by VexedPanda

While the img tag is required, I'm not sure outputting a blank one is going to help matters. I'm also unsure there's any reasonable way to force a developer to supply that text (we could throw an exception on render, but that seems heavy-handed).

I'm all for creating a new bug requesting Title support for QImageButton and other img outputting controls.

  Changed 4 years ago by kmeirlaen

 http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8 says:

---
Do not specify irrelevant alternate text when including images intended to format a page, for instance, alt="red ball" would be inappropriate for an image that adds a red ball for decorating a heading or paragraph. In such cases, the alternate text should be the empty string (""). Authors are in any case advised to avoid using images to format pages; style sheets should be used instead.
---

as said several times, alt is required, so if not present, the page should not pass W3C validation. an empty tag is allowed/recommended by W3C.

  Changed 4 years ago by VexedPanda

Ok, I hadn't thought that empty strings were recommended. If that's the case, then I'm all for forcing the render.

Note: See TracTickets for help on using tickets.