Home > other >  CSS Styling is not changing style / throwing error
CSS Styling is not changing style / throwing error

Time:01-31

I'm very new to website designing an am trying to change the background colour of a button, but for some reason it's not working. Could someone please help?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="widthz=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="styles.css">
    <title>Title</title>
</head>
<body>
    <script src="application.js"></script>
    <h3>Small Header</h3>
    <button id="InformationButton">Information</button>
</body>
</html>

styles.css:

.InformationButton {
    background-color: aqua;
    border : solid;
}

CodePudding user response:

Since you have used id to refer the button in your HTML, you should be using the id selector (#) instead of the class selector(.).

Thus replace your CSS as below.

#InformationButton {
    background-color: aqua;
    border : solid;
}

Read more about CSS selectors in the docs

CodePudding user response:

You are using a CSS ID selector to refer to your button. Either change the CSS to a class selector :

#InformationButton {
    background-color: aqua;
    border : solid;
}

or change your button element to

<button >Information</button>
  •  Tags:  
  • Related