大家好,欢迎来到freecodecamp HTML专题,今天是专题的第9篇文章。
今天的挑战关于HMLT5当中的a
标签。
在网页当中我们可以使用a
标签来制作一个超链接。
a
元素需要一个网站地址作为目的地,这个网址叫做href
属性。我们同样也需要一段文本,来作为超链接的提示语,我们来看一个例子:
<a href="https://freecodecamp.org">this links to freecodecamp.org</a>
当我们把这段代码嵌入在网页当中之后,我们的浏览器就会显示文本“this links to freecodecamp.org”,这段文本会被作为一个超链接展示,我们可以通过点击它访问对应的网站(https://freecodecamp.org)
创建一个a
元素指向https://freecatphotoapp.com,将“Cat photos”作为它的提示文本。
a
元素必须拥有文本:Cat photosa
元素a
元素需要有一个closing tag虽然编辑器当中的代码很多,但是我们都不需要改,我们只需要按照题目的要求加上一个a
标签即可。
<h2>CatPhotoApp</h2>
<main>
<a href="https://freecatphotoapp.com">Cat photos</a>
<img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>