Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS file not loading in basic HTML

Tags:

html

css

loading

this is very basic code as I'm still a beginner, I'm having trouble getting it to load into Chrome via Brackets on OSX.

When I load the file locally it displays everything but the CSS is not loading, everything else is functioning properly.

My troubleshooting so far:

  1. index.html and my tutoringservices.html are in the same directory as style.css.
  2. I've saved and restarted my computer to make sure it wasn't a refresh issue
  3. Cleared Chrome's cache to make sure the CSS was being loaded properly
  4. I've copypasted CSS code from w3schools.com and other basic websites to make sure the basic code would function properly. I removed everything but the .button styling, as that's what I was originally trying to troubleshoot, not so much the font import.

I don't know how open Firefox thru Brackets so I have not loaded Firebug.

I have not yet linked the CSS to my index.html as in theory it should work on tutoringservices.html anyhow. Here's my code:

tutoringservices.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Contact</title>
    
    <link href="https://fonts.googleapis.com/css2?family=Amatic+SC&display=swap" rel="stylesheet">
   
    <link href="./style.css" rel="stylesheet" type="text/css" media="screen, projection"/>
    
    
</head>

<body>
    
    <header>
      <a href="index.html">Home</a>

    </header>
  <main>
      <h1>Get in Touch</h1>
      <hr>
      <p>
          Thank you for your interest. Inquiries usually receive a response within 24 hours. 
          <br>If you do not receieve a timely response, please feel free to send another!</p>
      
    <form class="contact-form" action="contactform.php" method="post">
      <input type="text" name="name" placeholder="Full name">
        <br><br>
      <input type="text" name="mail" placeholder="Your E-Mail">
        <br><br>
      <input type="text" name="phone" placeholder="Phone Number (optional)">
        <br><br>
      <input type="text" name="subject" placeholder="Subject">
        <br><br>
      <textarea name="message" placeholder="Message"></textarea>
        <br><br>
      <button type="submit" name="submit">SEND</button>
    </form>
  </main>
</body>
</html>

style.css

@charset "UTF-8";

.paragraph {
    font-size: 50px;
    line-height: 62px;
    font-family: 'Amatic SC', cursive;
}

font-family: 'Amatic SC', cursive;

.button {
  background-color: #4CAF50; /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
}

Be happy to answer any additional questions, thanks for your time.

like image 449
coloradopowpow Avatar asked Sep 02 '26 10:09

coloradopowpow


2 Answers

The .name in the css file indicates it is styling a class, but the classes are not used in the HTML file. So .button means it styles the button class instead of the button element. Two options:

  1. Style the element instead of the class by removing the dot

  2. Add the class to the css file, for example on the button:

      <button class="button" type="submit" name="submit">SEND</button>
    
like image 156
Qodeer Avatar answered Sep 04 '26 04:09

Qodeer


  1. Use classes in your HTML code. In your CSS you use, for example, .paragraph - so use it in HTML as well: <p class="paragraph">, and the same for button.

  2. Second issue is a little bit more tricky to spot, but easier to fix. You have a wayward CSS declaration outside of any selector in your style.css file, on line 9. Simply remove it:

    font-family: 'Amatic SC', cursive;

Do those two fixes and you will be golden.

like image 29
PLW Avatar answered Sep 04 '26 02:09

PLW



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!