0

I'm completely new to coding, so please be gentle with me! I'm trying to add CSS code to a button, I've tested it in Codepen which shows it as working, but when I've tried it in my browser, it's coming up with a hyperlink, then the code alongside it.

<a href="index.html" class="button">Home</a>

        .button 
        {padding: 10px 24px;
        font-family: trebuchet;
        Color: #E8DCEC;
        Background-color: #ed1c24;
        text-align: center;
        display: inline-block;
        font-size: 16px;
        border: 2px solid #8b52a1;
        border-radius: 4px;}

        .button:hover {
        background-color: #72bf44
        color: #E8DCEC; }

I'm sure I've missed something totally obvious here, but I've looked over it so much and I can't see anything

1
  • 3
    Are you putting your CSS inside <style></style> tags? Codepen does that for you automatically. If not, you should probably read up on the basics of an HTML page. Commented Jan 20, 2017 at 21:23

1 Answer 1

1

CSS code needs to be in <style> or linked in an external CSS document via a link tag

<a href="index.html" class="button">Home</a>
<style>
.button {
  padding: 10px 24px;
  font-family: trebuchet;
  Color: #E8DCEC;
  Background-color: #ed1c24;
  text-align: center;
  display: inline-block;
  font-size: 16px;
  border: 2px solid #8b52a1;
  border-radius: 4px;
}

.button:hover {
  background-color: #72bf44 color: #E8DCEC;
}
</style>

Sign up to request clarification or add additional context in comments.

1 Comment

Amazing, thanks so much! I have recently done foundation diplomas in web design and web development, but this is my first attempt at anything practical .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.