Home > Article > Web Front-end > How to use href in css
In CSS, the full name of href is Hypertext Reference, which is used to specify the target of the link. Its syntax is href="URL", which can be used to: Link external files (such as style sheets) Create intra-page links Reference external images Set background images
##Usage of href in CSS
What is href?
The full name of href is Hypertext Reference, which means hypertext reference. In CSS, href is used to specify the target of a link (the content the link points to).How to use href
In CSS, the href attribute is used for link elements, such as tags or
< ;link> tag. The syntax is:
<code class="css">href="URL"</code>where URL represents the target address to be linked.
Uses
The href attribute has many uses in CSS, including: tag to link to an external style sheet or font file.
tags to create links to different parts of the page.
tag to reference external images.
attribute to link the background image.
Example
<code class="css"><link rel="stylesheet" href="style.css"></code>
<code class="css"><a href="#section-1">Section 1</a></code>
<code class="css"><img src="image.jpg" alt="My Image"></code>
<code class="css">background-image: url("background.jpg");</code>
The above is the detailed content of How to use href in css. For more information, please follow other related articles on the PHP Chinese website!