I need a link within an tag as follows:
<span><a data-description="TITLE - See more here" class="bullet" tabindex="-1"</a></span>
How can I have a link on the 'see more here' part?
Is this even possible?
Thanks
The "data-description" attribute is by definition, without any universal semantic meaning (any attribute beginning in "data-"). It might be used by some JavaScript library to add a tooltip, but the only built-in browser tooltip is the "title" attribute which your example is not using (and that does not support HTML, only text). You need to use some library like http://docs.jquery.com/Plugins/Tooltip
Related
Which one is the correct way or using a tag in this context?
<a name="test">Test</a>
or
<a name="test></a>Test
the correct is the first one
Test
The first example is correct
<a name="test">Test</a>
The correct syntax is link text
"name" is not a valid attribute for <a> tag. The allowed attributes are:
download, href, hreflang, media, ping , referrerpolicy, rel, target and type. Of course, <a> tag also allows global attributes and event attributes in addition to these.
If you want to use custom attributes consider using data- format like data-name
eg.
link text
What is the significance of cmdValue in the input tag in the following:
<input type="button" value="Bold" cmdValue="bold">
This is from <div id="actions"> on a website.
I looked up the input tag on several HTML reference sites and searched for cmdValue in conjunction with the input tag, but could find no data.
That is not a formal HTML attribute for any known tag.
That is certainly a customized attribute added by the developers of that website.
I prefer to forward you to read the answers of this question.
The significance is whatever the CSS or JavaScript code for the page assigns to it. You would need to analyze the page in detail to find this out.
As such, the nonstandard has no effect beyond getting inserted into the DOM as an attribute.
Is it ok to put html codes inside alt tags?
I have a slider that uses alt tags for description. In order style the description, I have to put html codes.
My problem is I dont know if it will harm SEO or any other things to consider..
HTML markup is not valid for the contents of the alt attribute. If you need a fancy dialog ox you can easilt accomlish this with JavaScript and maye even plain old CSS. That way your code is valid and you don't run into any potential SEO issues.
Yes, you can use <img src=foo alt="<i>Hello</i> world">. I don’t see any reason why anyone would, but it’s valid. The alt attribute would then be rendered literally, because it’s an attribute value; no HTML tags are recognized there.
The rendering of alt tag values may or may not be affected by style sheets and markup around the tag. If you write <b><img src=foo alt="<i>Hello</i> world"></b>, then advanced browsers will display <i>Hello</i> world in bold face (but not in italic), when they do not display the image. (The “tooltip” part of the handling of alt attributes is a different issue, unstyleable, and generally not present in any modern browser.)
To use just an attribute that carries some text to be displayed via JavaScript, data-* attributes are a much better approach, as Baptiste Placé points out in his answer. It is technically possible to use alt for that, but this would cause odd things when the image is not displayed (at least temporarily, due to delays) ant the alt text is used in its stead.
Moreover, search engines are known to play attention to alt attribute values, so they should not contain anything that is nonsensical when considering the attribute’s defined role (to provide an alternative text to be used when the image is not shown).
In order to style the description, you need CSS; HTML is for defining a document's structure.
You should not use the alt attribute for your slider, use your own property instead with the data-* attributes. More info on the data attribute : http://www.marcofolio.net/webdesign/html5_data-_attributes_are_great_and_you_know_it.html
You should make this kind of html (using data-longdescr, but use any data-something you like) :
<img src="/img/pic.jpg" alt="Jumping over a fence" data-longdescr="<b>Jumping</b> over a fence" />
Beware of quotes thought, they must be escaped !
Markup won't work on an alt attribute.
I would put all the description tags inside a CSS class. Then, style the class separately.
I think you've all misunderstood the question, OP is asking if it's possible to insert html in to an alt tag because he wanted to style the output text as he was using it as descriptive text overlaying his slides. I've run in to the same problem and discovered it is possible to insert html in to alt tags. This is very handy since I'm using a Wordpress lightbox plugin that turns every picture link on my page in to part of a slideshow and outputs the alt text as descriptive text over each image.
If I could only enter plain text then the styling for my descriptions would have been very limited and I wouldn't be able add in awesome things like links:
<img alt="<?php echo "Title" . "Lorem Ipsum dolor" . "<a href='http://www.google.com'>View Website</a>"; ?> " src="<?php echo $img; ?>">
I'm using php to insert the markup though you can also use plain html
alt="<h3>Title</h3><p>Lorem Ipsum dolor</p><a href='http://www.google.com'>View Website</a>"
Which outputs:
Title
Lorem Ipsum dolor
View Website
I'm not sure if this good for SEO but it's definitely handy and something I didn't know was possible until now.
in an href in html, whats the difference between using
<a href="http://www.somesite.com/" name="The Name">
and
<a href="http://www.somesite.com/" title="The Name">
Is there any advantage to using one over the other?
Thanks
Look it up in the spec, or better yet a resource that condenses the spec a bit. (And, then the spec if that isn't enough.)
title text Specifies extra information about an element
http://www.w3schools.com/tags/tag_a.asp
The name attribute specifies the name
of an anchor.
The name attribute is used to create a
bookmark inside a document.
The href or the name attribute must be
present in the tag
http://www.w3schools.com/tags/att_a_name.asp
So, the name of the anchor is used for links like exampledomain.com/index.php#some_section, which would bring that anchor into focus on the page.
Many modern browsers will display the title attribute in a tooltip when hovering over the link. It's likely also useful for screen readers and such.
markup tag Node
- Name -- is to identify the element and for lookup
- title -- is default toolTip property. like ALT
Below is some html I found in this jquery tooltip tutorial, the contents inside of content"" show up in the tooltip using javascript. I have never seen the content propert befre, I search on W3schools.com but and google but could not find anything about it. Is this a valid property?
Image Tooltip
sorry If I am overlooking this, I searched but just briefly, didn't look too much before asking this.
If you need to put custom attributes into an element, then use the html5 data- attributes.
Shamelessly copied from John Resig:
<li class="user" data-name="John Resig" data-city="Boston"
data-lang="js" data-food="Bacon">
<b>John says:</b> <span>Hello, how are you?</span>
</li>
This is most likely a custom attribute that the jQuery tooltip creators made up to hold the text for the tooltip. This is unfortunately a common practice with many jQuery plugins (although most put stuff like this in the rel="" attribute instead).
The downside of this is that if you are concerned with validatiing your HTML, this will cause that to fail.
The upside is that browsers will ignore attributes that they do not expect, so it will not affect the rendering of the page.
The proper place for this would be the title="" attribute, but without the extra HTML markup in the value (<span> in this case).
If you must have the extra markup, be sure to encode it:
title=">span<Image Title</span>"
But, be aware that if the Javascript fails, the user will see this encoded text as the built-in, browser-rendered tooltip.
Based on my initial searches on w3c, it seems that there is not such attribute "content" for a tag. The "content" attribute is for meta tag only. For tooltips you would use the "title" attribute. Also, I don't think html is allowed in a title attribute.
Image Tooltip
The content attribute doesn't exist. For tooltips you can use the title attribute (which works on alot of tags).
I thinks some browsers also use the alt attribute for tooltips on img tags, but this isn't the intended purpose of alt.