HTML target

Created By: chatGPT

In HTML, the target attribute is used within anchor (<a>) tags to specify where to open the linked document. This attribute accepts several values that control how the link behaves when clicked.
<a href="https://example.com" target="_blank">Open Example</a>

Common values for the target attribute include:

  • _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 the default behavior).
  • _parent: Opens the linked document in the parent frame.
  • _top: Opens the linked document in the full body of the window, removing any frames.
<a href="https://example.com" target="_self">Open in the Same Window</a>
Using the target attribute can improve user experience, especially when linking to external content. Always consider the context to decide if opening in a new window/tab is appropriate.
<a href="https://external-site.com" target="_blank">Visit External Site</a>

Example of using targets with iframes: If you're embedding an iframe, you may also control where links within the iframe go by manipulating the target parameter based on the context of the parent window. Here's an example of how you might set up an iframe with links that utilize various target attributes.

<iframe src="page-with-links.html"></iframe>
Introduction And SetupHeadTitleMetaLinkStyleScriptBodyHeaderNavSectionArticleAsideFooterH1H2H3H4H5H6PBlockquoteOlUlLiAImgTableTrTdThCaptionFormInputTextareaButtonSelectOptionLabelFieldsetLegendCanvasSvgVideoAudioEmbedObjectIframeDivSpanStrongEmSmallSubSupMarkCiteDfnAbbrTimeDataVarCodeKbdSampQCiteRubyRbRtRtcRpBdiBdoWbrDatalistOutputProgressMeterDetailsSummaryTemplatePictureSourceTrackMeta CharsetMeta NameMeta ContentMeta ViewportMeta Http EquivLink RelLink HrefScript SrcScript AsyncStyle TypeBody OnloadIdClassStyleSrcHrefAltTitleValueNameTypePlaceholderDisabledReadonlyCheckedActionMethodForMaxlengthMinlengthAutocompleteTargetRelData *WidthHeightLangTabindexAria *DraggableHiddenAutofocusRequiredDownload