I would like to ask the community to help me understand what is a Document Base URL and Fallback Base URL in terms of how they are defined in the HTML5's specification. Please note I would prefer to expect a more understandable definition in terms of the definitions in the specification. However, individual perceptions are also welcome.
Link for Document Base URL's definition.
Link for Fallback Base URL's definition.
To me the definition for these two in the HTML5's specification kind of looks like having a circular reference.
You obviously need to understand recursion to understand recursion... ;) – These kinds of specifications are often self-referential. In the end they're very specific steps described in excruciating detail; they're essentially pseudo-code written in English as the programming language. You just need to follow them step by step to get to the result. One part referring to another term is like calling a function in code; they may even call each other, as long as there's no infinite loop in the end that's fine.
In this case it's not really that bad. The fallback base URL describes how to resolve a document's URL assuming cases where it may be a child of another document like an iframe, in which case it falls back to the parent's URL.
The document base URL resolves a document's URL taking <base> elements into account.
In summary, the specification is:
The document base URL is either the document's URL or the appropriately resolved <base> URL.
If the document is an iframe, take the parent's document base URL (see above).
Otherwise if it's about:blank but has a parent, take the parent's document base URL (see above). (This is a real niche case, but required for completeness.)
Otherwise it's the documents's address.
If the specification is henceforth talking about the document base URL, it just means step 1., the document's own URL, possibly resolved against <base>. If the specification is talking about the fallback base URL, follow all these steps.
What is "_newtab" value for target attribute in HTML "a" tag? I can't find information about the compatibility for browsers.
Does it will work in all modern browsers?
How it will work if in browser option users set to open links in new window and not in new tab?
Does this value is described anywhere in HTML standards?
Are you sure, whether it is _new or _newtab?
There is no value called _newtab for target attribute.
May this SO answer gives us a better information,
Using target="_new" is technically invalid according to the
specifications, but as far as I know every browser will behave the
same way:
it will search for a tab or window with the context name "_new" *
if a "_new" tab/window is found, then the URL is loaded into it * if
it's not found, a new tab/window is created with the context name
"_new", and the URL loaded into it
Note target="_new" will behave exactly the same as target="new",
and the latter is valid HTML while the former is invalid HTML.
These are possible values for target attribute: _blank, _self, _parent, or _top
I think what you're trying to refer is target-new, a CSS3 property.
The target-new property specifies whether new destination links should
open in a new window or in a new tab of an existing window.
target-new:window; //Opens a link in new window
target-new:tab; //Open a link in new tab
Note: The target-new property is not supported in any of the major browsers.
I'm having some problems supporting Internet Explorer 8 in my application.
When a user clicks on a link in non-IE8 browsers, the link works fine and goes to the correct position on the page. Using Internet Explorer 8, however, the links only work when the it doesn't take all of the screen.
To better describe the problem, I took the following screenshots:
DOESN'T WORK
WORKS
Links on the first page appear as such:
The IDs for links appear as such:
<a id="fibra1537"></a>
What is happening?
I would try to use the name attribute in addition to the id attribute.
<a id="fibra1537" name="fibra1537"></a>
EDIT: #greg explains why here
For HTML documents (and the text/html MIME type), the following processing model must be followed to determine what the indicated part of the document is.
Parse the URL, and let fragid be the <fragment> component of the URL.
If fragid is the empty string, then the indicated part of the document is the top of the document.
If there is an element in the DOM that has an ID exactly equal to fragid, then the first such element in tree order is the indicated part of the document; stop the algorithm here.
If there is an a element in the DOM that has a name attribute whose value is exactly equal to fragid, then the first such element in tree order is the indicated part of the document; stop the algorithm here.
Otherwise, there is no indicated part of the document.
Can anyone explain the meaning of the attribute complete?
I read somewhere that it might have to do with DOM.
<img src="/folder/pic.jpeg" complete="complete" />
The attribute complete has no defined meaning by specifications, and it probably has no effect (though it can be read with the getAttribute() method). So the code in the question is probably based on some misunderstanding.
According to HTML5 drafts, there is the complete property for an object corresponding an img element, as per the HTMLImageElement interface. The definition of the complete property basically means that the value is true when the browser has completely received the image (though there are some nuances here). As this is to be controlled by the browser, reflecting the loading status, it is natural that the property is defined to be read-only.
This property is widely present browsers, but apparently in a broken way: if you have an img element that refers to a nonexistent resource (404 Not Found), then Chrome and Firefox indicate the property as having the value true (IE gets things right here: false). So the property is not of much use for the time being.
Setting an attribute in HTML has no effect on this. HTML attribute and element object properties correspond to each other only when a correspondence has been defined.
It's set when the image has been downloaded.
I've never seen it explicitly in the HTML like in your example (MDN says it's not an attribute for a img element) . I just use to check if the image has been downloaded with JavaScript (there are cross browser issues with that, however). The property on a HTMLImageElement returns a Boolean.
[].forEach.call(document.querySelector("img"), function(img) {
// Loaded?
img.complete && (img.style.border = "5px solid #f00");
});
It is used to check if the image has finished loading.
document.getElementsByTagName('img')[0].complete
returns true if has finished loading, else false.
However it is not used as an attribute like in your example.
What's the difference between <a target="_new"> and <a target="_blank"> and which should I use if I just want to open a link in a new tab/window?
Use "_blank"
According to the HTML5 Spec:
A valid browsing context name is any string with at least one character that does not start with a U+005F LOW LINE character. (Names starting with an underscore are reserved for special keywords.)
A valid browsing context name or keyword is any string that is either a valid browsing context name or that is an ASCII case-insensitive match for one of: _blank, _self, _parent, or _top." - Source
That means that there is no such keyword as _new in HTML5, and not in HTML4 (and consequently XHTML) either. That means, that there will be no consistent behavior whatsoever if you use this as a value for the target attribute.
Security recommendation
As Daniel and Michael have pointed out in the comments, when using target _blank pointing to an untrusted website, you should, in addition, set rel="noopener". This prevents the opening site to mess with the opener via JavaScript. See this post for more information.
Using target="_blank" will instruct the browser to create a new browser tab or window when the user clicks on the link.
Using target="_new" is technically invalid according to the specifications, but as far as I know every browser will behave the same way:
it will search for a tab or window with the context name "_new"
if a "_new" tab/window is found, then the URL is loaded into it
if it's not found, a new tab/window is created with the context name "_new", and the URL loaded into it
Note target="_new" will behave exactly the same as target="new", and the latter is valid HTML while the former is invalid HTML.
Adding some confusion to this, in HTML4 the target attribute was deprecated. In HTML5 this decision was reversed, and it is an official part of the spec once again. All browsers support target no matter what version of HTML you are using, but some validators will flag the use as deprecated if your doctype is HTML4.
TL;DR
USE _blank
The target attribute specifies where to open the linked document.
USAGE: target="xyz" [don't forget double quotes]
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
framename Opens the linked document in a named frame
SINCE "_new" is not any of these IT WILL COME UNDER "framename" so if a user re-clicks on that hyperlink it will not open a new tab instead update the existing tab. Whereas in _blank if user clicks twice then 2 new tabs open.
I know this is an old question and the correct answer, use _blank, has been mentioned several times, but using <a target="somesite.com" target="_blank">Link</a> is a security risk.
It is recommended (performance benefits) to use:
Link
This may have been asked before but:
"every link that specifies target="_new" looks for and finds that window by name, and opens in it.
If you use target="_blank," a brand new window will be created each time, on top of the current window."
from here: http://thedesignspace.net/MT2archives/000316.html
target="_blank" opens a new tab in most browsers.
it's my understanding that target = whatever will look for a frame/window with that name. If not found, it will open up a new window with that name. If whatever == "_new", it will appear just as if you used _blank except.....
Using one of the reserved target names will bypass the "looking" phase. So, target = "_blank" on a dozen links will open up a dozen blank windows, but target = whatever on a dozen links will only open up one window. target = "_new" on a dozen links may give inconstant behavior. I haven't tried it on several browsers, but should only open up one window.
At least this is how I interpret the rules.
Caution - remember to always include the "quotes" - at least on Chrome, target=_blank (no quotes) is NOT THE SAME as target="_blank" (with quotes).
The latter opens each link in a new tab/window. The former (missing quotes) opens the first link you click in one new tab/window, then overwrites that same tab/window with each subsequent link you click (that's named also with the missing quotes).
_blank as a target value will spawn a new window every time,
_new will only spawn one new window.
Also, every link clicked with a target value of _new will replace the page loaded in the previously spawned window.
You can click here When to use _blank or _new to try it out for yourself.
The target attribute of a link forces the browser to open the destination page in a new browser window. Using _blank as a target value will spawn a new window every time while using _new will only spawn one new window and every link clicked with a target value of _new will replace the page loaded in the previously spawned window
In order to open a link in a new tab/window you'll use <a target="_blank">.
value _blank = targeted browsing context: a new one: tab or window depending on your browsing settings
value _new = not valid; no such value in HTML5 for target attribute on a element
target attribute with all its values on a element: video demo
The use of _New is useful when working on pages that are Iframed. Since target="_blank" doesn't do the trick and opens the page on the same iframe... target new is the best solution for Iframe Pages. Just my five cents.