A href html w3schools

Тег атрибут href

Атрибут href указывает URL адрес страницы, на которую переходит ссылка.

Совет: Вы можете использовать href=»#top» или href=»#» чтобы перейти по ссылке в верхнюю часть текущей страницы!

Если атрибут href отсутствует, тег не является гиперссылкой.

Поддержка браузеров

Синтаксис

Значение атрибута

  • Абсолютный URL адрес — указывает на другой сайт (например, href=»http://www.example.com/default.htm»)
  • Относительный URL адрес — указывает на файл внутри веб сайта (например, href=»default.htm»)
  • Ссылка на элемент с указанным идентификатором внутри страницы (например, href=»#section2″)
  • Другие протоколы (например, https://, ftp://, mailto:, file:, и т.д.)
  • Сценарий (например href=»javascript:alert(‘Пивет’);»)

Еще примеры

Пример

Как использовать изображение в качестве ссылки:

Пример

Как перейти по ссылке на адрес электронной почты:

Пример

Как подключиться к номеру телефона:

Пример

Как перейти по ссылке на другой раздел на той же странице:

Читайте также:  Html input types width

Пример

Как связаться с JavaScript:

Мы только что запустили
SchoolsW3 видео

ВЫБОР ЦВЕТА

colorpicker

Сообщить об ошибке

Если вы хотите сообщить об ошибке или внести предложение, не стесняйтесь отправлять на электронное письмо:

Ваше предложение:

Спасибо Вам за то, что помогаете!

Ваше сообщение было отправлено в SchoolsW3.

ТОП Учебники
ТОП Справочники
ТОП Примеры
Получить сертификат

SchoolsW3 оптимизирован для бесплатного обучения, проверки и подготовки знаний. Примеры в редакторе упрощают и улучшают чтение и базовое понимание. Учебники, ссылки, примеры постоянно пересматриваются, чтобы избежать ошибок, но не возможно гарантировать полную правильность всего содержания. Некоторые страницы сайта могут быть не переведены на РУССКИЙ язык, можно отправить страницу как ошибку, так же можете самостоятельно заняться переводом. Используя данный сайт, вы соглашаетесь прочитать и принять Условия к использованию, Cookies и политика конфиденциальности.

Источник

HTML Tag

By default, links will appear as follows in all browsers:

  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red

Tips and Notes

Tip: A linked page is normally displayed in the current browser window, unless you specify another target.

Tip: Use CSS to style links: CSS Links and CSS Buttons.

Browser Support

Attributes

Attribute Value Description
download filename Specifies that the target will be downloaded when a user clicks on the hyperlink
href URL Specifies the URL of the page the link goes to
hreflang language_code Specifies the language of the linked document
media media_query Specifies what media/device the linked document is optimized for
ping list_of_URLs Specifies a space-separated list of URLs to which, when the link is followed, post requests with the body ping will be sent by the browser (in the background). Typically used for tracking.
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin-when-cross-origin
unsafe-url
Specifies which referrer information to send with the link
rel alternate
author
bookmark
external
help
license
next
nofollow
noreferrer
noopener
prev
search
tag
Specifies the relationship between the current document and the linked document
target _blank
_parent
_self
_top
Specifies where to open the linked document
type media_type Specifies the media type of the linked document

Источник

Links are found in nearly all web pages. Links allow users to click their way from page to page.

HTML links are hyperlinks.

You can click on a link and jump to another document.

When you move the mouse over a link, the mouse arrow will turn into a little hand.

Note: A link does not have to be text. A link can be an image or any other HTML element!

The link text is the part that will be visible to the reader.

Clicking on the link text, will send the reader to the specified URL address.

Example

This example shows how to create a link to W3Schools.com:

By default, links will appear as follows in all browsers:

  • An unvisited link is underlined and blue
  • A visited link is underlined and purple
  • An active link is underlined and red

Tip: Links can of course be styled with CSS, to get another look!

By default, the linked page will be displayed in the current browser window. To change this, you must specify another target for the link.

The target attribute specifies where to open the linked document.

The target attribute can have one of the following values:

  • _self — Default. Opens the document in the same window/tab as it was clicked
  • _blank — Opens the document in a new window or tab
  • _parent — Opens the document in the parent frame
  • _top — Opens the document in the full body of the window

Example

Use target=»_blank» to open the linked document in a new browser window or tab:

Absolute URLs vs. Relative URLs

Both examples above are using an absolute URL (a full web address) in the href attribute.

A local link (a link to a page within the same website) is specified with a relative URL (without the «https://www» part):

Example

Absolute URLs

W3C

Google

Relative URLs

HTML Images

CSS Tutorial

To use an image as a link, just put the tag inside the tag:

Example

Use mailto: inside the href attribute to create a link that opens the user’s email program (to let them send a new email):

Example

To use an HTML button as a link, you have to add some JavaScript code.

JavaScript allows you to specify what happens at certain events, such as a click of a button:

Example

Tip: Learn more about JavaScript in our JavaScript Tutorial.

The title attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves over the element.

Источник

HTML href Attribute

The href attribute specifies the URL of the page the link goes to.

If the href attribute is not present, the tag will not be a hyperlink.

Tip: You can use href=»#top» or href=»#» to link to the top of the current page!

Browser Support

Syntax

Attribute Values

  • An absolute URL — points to another web site (like href=»http://www.example.com/default.htm»)
  • A relative URL — points to a file within a web site (like href=»default.htm»)
  • Link to an element with a specified id within the page (like href=»#section2″)
  • Other protocols (like https://, ftp://, mailto:, file:, etc..)
  • A script (like href=»javascript:alert(‘Hello’);»)

More Examples

Example

How to use an image as a link:

Example

How to link to an email address:

Example

How to link to a phone number:

Example

How to link to another section on the same page:

Example

How to link to a JavaScript:

Unlock Full Access 50% off

COLOR PICKER

colorpicker

Join our Bootcamp!

Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

Thank You For Helping Us!

Your message has been sent to W3Schools.

Top Tutorials
Top References
Top Examples
Get Certified

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Источник

HTML href Attribute

For elements, the href attribute specifies the base URL for all relative URLs on a page.

For elements, the href attribute specifies the location (URL) of the external resource (most often a style sheet file).

Applies to

The href attribute can be used on the following elements:

Examples

A Example

The href attribute specifies the link’s destination:

Area Example

An image map, with clickable areas:

usemap=»#planetmap»>

Base Example

Specify a base URL for all relative URLs on a page:

Link to an external stylesheet:

Browser Support

The href attribute has the following browser support for each element:

Element
a Yes Yes Yes Yes Yes
area Yes Yes Yes Yes Yes
base Yes Yes Yes Yes Yes
link Yes Yes Yes Yes Yes

Unlock Full Access 50% off

COLOR PICKER

colorpicker

Join our Bootcamp!

Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

Thank You For Helping Us!

Your message has been sent to W3Schools.

Top Tutorials
Top References
Top Examples
Get Certified

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Источник

Оцените статью