skip to Main Content

I’m currently learning HTML CSS and am trying to implement a hyperlink to my work email.
My current line of code doesn’t have any problems I think but I don’t know how to add a email Hyperlink

This is my line of code and I see no issues even after inspecting it multiple times, and if it looks bad I’m sorry, first post here and I’m new to programming.

<Doctype html>
<head>Work Website</html>
 <hr>
<body>
<p href= "[email protected]">Email me.</p>
</body>

4

Answers


  1. This is basic HTML; instead of trying to apply the href attribute to the p tag, you should be using the a tag:

    <a href="mailto:foo@bar">Email me at foo@bar</a>
    
    Login or Signup to reply.
  2. This <p> tag is used for paragraphs. For links, you need to use an anchor with this tag <a>.

    <p><a href="email.com">My email</a></p>
    Login or Signup to reply.
  3. To create a hyperlink that allows users to email you, you need to use an tag with the mailto: scheme in the href attribute. Your current code uses a

    tag, which is not meant for hyperlinks.

    <p><a href="mailto:[email protected]">Email me.</a></p>
    Login or Signup to reply.
  4. There are some issues with your code structure. The structure of your HTML code should be as follows:

    <!DOCTYPE HTML>
    <html>
    <head>
    ...
    </head>
    <body>
    ...
    </body>
    </html>
    

    <p> tag is used for defining paragraphs. It cannot be used along with the href attribute.

    In order to create a hyperlink to link to other pages, email addresses etc. you need to use the <a> (anchor) tag along with the href attribute.

    You need to use the mailto parameter inside the href attribute to link to email addresses.

    This will work:

    <a href="mailto:[email protected]">Email me.</a>
    

    If you wish, you can also add it inside a paragraph like this:

    <p><a href="mailto:[email protected]">Email me.</a></p>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search