Alt or title attribute for Cross-browser HTML tooltip? - html

I'm looking for a cross browser solution to display information when "hovering" on an element, I know this can be done with JS dynamically but I'd prefer in this specific case a basic static HTML solution.
According to mozilla developers website (here) using title instead of alt is the best practice but I'd like more "field experience" to help me decide if I should go for ALT, TITLE attr or JavaScript
Thank you very much

Title attribute is for tooltips and is supported by all major browser. You should use it.
Alt attribute isn't about tooltips at all.

Related

I have a simple question regarding alt and title

I have a really simple question.
In HTML links (a href), can I use title and alt? Or only Title?
I know for images title and alt can be used at the same time. But what about links as I have mentioned?
Thank you.
Trying to get an answer to a simple question.
Example:
test
I have searched online but couldn't find a definitive answer.
some browser will not support your image or link or title that is why we always use alt. alt is alternative text which shuld be shown when an image or link is not supported by browser
some browser will not support your image.link is not supported by browser

Is alt="" ONLY readable for images?

I would like to use the alt attribute so I can use it for my search widget in WordPress.
I am using elementor and WordPress editor so I can add the attributes with HTML.
<h3 alt="seawater">seawater</h3>
I tried this code and went to my search widget but the results weren't what I expected.
I know I can use YOAST plugin so maybe I should dig into that instead.
I would like to do an SEO for the paragraphs that are important on the website.
The "alt" attribute is used as an alternative information for an image if for some reason that image can't be loaded or if the user is using a screen reader.
For img tags, "alt" attribute is required.
You can also use it with area and input tags.
Regarding your question about SEO and Heading Tags, I think you should take a look at best practices about it. How and When to use them really matters if you're worried about SEO.
You can use alt only for <area>, <img> and <input> tags.

Is html title attribute a toolip?

I have question to know the truth. can some one tell me is HTML title attribute a tool tip.
Someone told me it is not a tooltip.
Can anybody describe what is a tool tip?
and HTML title is it or not?
I need the truth pleas.
It is "Advisory information for the element" according to the specification.
Some browsers render it as a tooltip when you hover the element.
Obviously a screen reader would not, it reads it out.
A touch screen browser would not, it doesn't support a hover state.
Html title attribute is not a tool tip. But browsers can display it as a tooltip.
The problem with this is that you no longer control what your website shows. You will depend on whether the browser wants to show it or not.
A tooltip is programmed so you can control the operation, and you can change it, add events, etc ...
https://www.w3schools.com/tags/att_title.asp
"The title attribute is part of the Global Attributes, and can be used on any HTML element."
It is simply an attribute, and the value of this attribute is being shown by most browsers when hovering over the element looking like a tool tip.
In my opinion, it actually is a tooltip, since the value of the attribute is shown when the user hovers his mouse over the element. But the styling and even if the value is being shown is up to the browser, and you have no control over it.
It just depends on what is a tooltip for you personally :)
Usually, "web people" refer to tooltips as popup content when hovering over an element. Usually, these tooltips are being shown using JavaScript or vanilly CSS.
https://www.w3schools.com/howto/howto_css_tooltip.asp
My 2 cents - but I think it's really up to one personally whether you think of it as a tooltip.
Html title attribute is not tool-tip but on hover of the element we can see the title the element
For Eg:
ABCD INFO
so we will get output as
enter image description here

Html Alert Element CSS

I tried to find resources about 'alert' element, but nothing came out.
<alert type="success">Your message</alert>
But I can use it without issue. How can I apply CSS styles to different alert's type?
You look like you are trying to use Bootstrap's 'alert' classes (e.g. 'success').
http://getbootstrap.com/components/#alerts
The only way to make that a semantic element like <alert /> that I know of is something like AngularJS: http://angular-ui.github.io/bootstrap/#/alert
In this case, it is all styled by Bootstrap, or whatever Bootstrap theme you are using.
First there is not an HTML tag alert. you can create an alert with javascript.
You cannot add style to an alert as it is produced by the browser by default.
Have a look to this post:
How do I style the alert box with CSS?
W3C is always a very credible source for HTML syntax.
http://www.w3.org/TR/html-markup/Overview.html#toc
Now for where you heard about an <alert> element I have no idea. Never heard of it, but that does not mean it does not exist. W3C does not have it in this "complete set of HTML elements". It may be an element something other than HTML
As far as I know, and as some others have pointed out, there is no alert element in HTML.
However, you can use it. To allow for the HTML evolution, any modern browser will accept happily any unkown element.
I am not saying it is a good practice to use whatever name you want for an element. I am saying that the browsers will accept it.
About giving it format, use standard practices. Give it a class, or an id, and reference that in the CSS. No problem .
Technically there is a tag but its for html5 and its not completly supported,There is a table at the end of this article that shows browser compatibility.
hope this is informative:
Native Popups and Modals With the HTML5 “dialog” Element
You could use Alertify.
It has pretty decent customization options.

Do I need to use title="" in this situation of HTML5?

When defining a title or alt to an anchor tag, which is valid HTML5?
Is it best to define both, or only one?
Does it affect SEO at all?
in HTML, even from version 4, the title attribute is valid for almost all elements. alt is different in that it's only valid for images, the idea being to provide a text only alternative version of the image, which would be useful to people with visual impairment (as they'd be able to hear their browser read the text)
It's good practice to provide an alt attribute for images, even if you're going to leave an empty string ( "" ). The alt attribute helps improve accessibility for screen readers since the user most likely can't see the image with which it's associated. The title is less useful for accessibility purposes but is still a good practice to get into.