PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 9, 2022

[FIXED] How to add hyperlink functionality with html and css

 November 09, 2022     css, html     No comments   

Issue

I have some HTML code that includes some css and I want the button to actually have a use like a hyperlink I press it and it takes me to a certain file or web address I have tried using actual hyperlinks inside the field but it looked ugly and I could only press on the hyperlink, I tried adding a HTML default hyperlink button but it cannot be colored.

Here's the code:

<html>
<body style="background-color:rgb(48, 45, 45)">
<font color="white">
<font color="#4CAF50">
<head>
<style>
.button {
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button1 {background-color: #4CAF50;}
.button2 {background-color: #008CBA;}
</style>
</head>
<body>
<button class="button button1">Green</button>
<button class="button button2">Blue</button>
</body>

Solution

Use an onclick element:

    <button onclick="goToStackOverflow()">Click Me</button> 
    <script>
        function goToStackOverflow() {
          document.location.href = "https://stackoverflow.com";
        }
    </script>

Or you could style an <a> element to look like a button

a {
  color: white;
  background-color: orange;
  text-decoration: none;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
}

a:hover {
  opacity: 0.8;
}

a:active {
  opacity: 0.6;
}
<a href="https://stackoverflow.com">Click Me</a>



Answered By - Emile Youssef FEGHALI EL
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing