90 likes | 204 Vues
In this chapter, we explore how to create hyperlinks using the <a> element in HTML. The <a> element enables you to link to other web pages, where the link text becomes clickable. We'll cover the importance of the href attribute, which specifies the destination of the link, and how browsers interpret these links upon user interaction. Additionally, we'll discuss the role of attributes in enhancing elements with extra information, ensuring your HTML is both functional and informative.
E N D
Creating Links in HTML—the HT Chapter 2
Creating Links <a> element</a> • The <a> element is used to create a link to another page • The content of the <a> element is the link text. • In the browser, the link text appears with an underline to indicate you can click on it
Creating Links • Once the text is in the link, you need to add HTML to tell the browser where to link the points to <a href=“elixir.html”>elixirs</a> • The href attribute is how you specify the destination of the lnk <a href=“directions.html”>driving directions</a>
Creating Links • Use the <a> element to create a hypertext link to another web page • The content of the <a> element becomes clickable in the web page • The href attribute tells the browser the destination of the link
Creating Links • When the user clicks on a link, the browser uses the href attribute to determine the page the link points to • If “elixirs” was clicked, the browser grabs the href value “elixir.html” • If “detailed directions” was clicked, the browser grabs the href value “directions.html”
Understanding Attributes • Attributes give you a way to specify additional information about an element <style type=“text/css”>--specifies style language <a href=“irule.html”>--tells you the destination of a hyperlink <imgsrc=“sweetphoto.gif”>--specifies the filename of a picture
Understanding Attributes • Example: • What if <car> were an element? • If <car> were an element, you would want to write something like this: • <car>My Red Mini</car> • But this <car> element only gives a descriptive name for your car—not the make, precise model, whether it is a convertible, etc. • So, if <car were really an element, you might want to use attributes like this: • <car> make=“Mini” model=“Cooper” convertible=“no”>My Red Mini</car>