Class in css und html wird nicht angesprochen, was tun?

Ich habe eine Frage zum Thema html und css. Die class .logo lässt sich nicht ansprechen und wenn ich mit vsc versuche verschiedene "classes" anzusprechen schlägt er mir nur alte gelöschte "classes" vor. Vielleicht kann mir ja jemand bei diesem Problem helfen Danke im vorraus :)

hier ist der Code:

index.html

<!DOCTYPE html>

 <html>

    <head>

        <link rel="stylesheet" href="style.css">

        <link rel="icon" href="">

        <title>beispiel</title>

    </head>

    <body>

    <nav>

      <ul class="topnav">  

                <li class="logo"><a href="beispielbild.jpg"></a></li>

                <li><a href="">Element 2.1</a></li>

                <li><a href="">Element 3.1</a></li>

                <li><a href="">Element 4.1</a></li>

                <li><a href="">Element 5.1</a></li>

                <li><a href="">Element 6.1</a></li>

                <li><a href="">Element 7.1</a></li>

                <li><a href="">Element 8.1</a></li>

            </ul>

      <ul class="leftnav">

                <li><a href="">Element 1</a></li>

                <li><a href="">Element 2</a></li>

          <li><a href="">Element 3</a></li>

                <li><a href="">Element 4</a></li>

                <li><a href="">Element 5</a></li>

                <li><a href="">Element 6</a></li>

                <li><a href="">Element 7</a></li>

                <li><a href="">Element 8</a></li>

            </ul>

      </nav>

    </body>

 </html>

style.css

* {

    margin: 0;

    padding: 0;

}

html {

    height: 100%;

}

body {

    background-color: rgb(214, 214, 214);

}

nav {

    width: 100%;

}

.leftnav {

    float: left;

    list-style: none;

    background-color: cadetblue;

}

.topnav {

    width: 100%;

    float: right;

    list-style: none;

    background-color: crimson;

    margin-bottom: 0;

}

nav .leftnav li {

    margin-left: 25px;

    margin-top: 30px;

    margin-right: 25px;

    margin-bottom: 30px;

}

nav .topnav li {

    float: right;

    display: inline-block;

    margin-right: 50px;

    margin-top: 20px;

    margin-bottom: 20px;

}

nav .topnav .firstlielement {

    display: inline-block;

    margin-right: 50px;

    margin-top: 20px;

    margin-bottom: 20px;

}

nav .topnav li a {

    text-decoration: none;

    color: white;

}

nav .leftnav li a {

    color: rgb(50, 60, 197);

    text-decoration: none;

}

nav .leftnav li a:hover {

    color: rgb(173, 174, 196);

    text-decoration: none;

}

nav .topnav li a:hover {

    color: rgb(81, 253, 1);

    text-decoration: none;

}

.logo {

}

HTML, Webseite, CSS, HTML5, Webdesign, Webentwicklung
was ist hier falsch gelaufen?
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Rocket vs Aliens</title>
  <style>
    canvas {
      background-color: gray;
    }
    
  </style>
  <script>
    let KEY_SPACE = false;
    let KEY_UP = false;
    let KEY_DOWN = false;
    let canvas;
    let ctx;
    let backgroundImage = new Image();
    let rocket = {
      x: 100,
      y: 200,
      width: 200,
      height: 80,
      src: 'img/rocket.png'
    };
    let spaceship = {
      x: 500,
      y: 200,
      width: 100,
      height: 40,
      src: 'img/spaceship.png'
    };
    document.onkeydown = function(e) {
      if (e.keyCode ==32) { // Leertaste gedrückt
        KEY_SPACE = true;
      }
      if (e.keyCode ==32) { // unten gedrückt
        KEY_SPACE = true;
      }
    
      if (e.keyCode ==38) { // Oben gedrückt
        KEY_UP = true;
      }
    }
    document.onkeyup = function(e) {
      if (e.keyCode ==32) { // Leertaste losgelassen
        KEY_SPACE = false;
      }
    
      if (e.keyCode ==38) { // oben losgelassen
        KEY_UP = false;
      }
      if (e.keyCode ==40) { // unten losgelassen
        KEY_DOWN = false;
      }
    }
    function startGame () {
      canvas = document.getElementById('canvas');
       ctx = canvas.getContext('2d');
      loadImages();
      draw();
      // calculate
    }
    function loadImages() {
      backgroundImage.src = 'img/background.png';
      rocket.img = new Image();
      rocket.img.src = rocket.src;
      spaceship.img = new Image();
      spaceship.img.src = spaceship.src;
    }
    function draw() {
      ctx.drawImage(backgroundImage, 0, 0);
      ctx.drawImage(rocket.img, rocket.x, rocket.y, rocket.widht, rocket.height);
      
      requestAnimationFrame(draw);
    }
  </script>
</head>
<body onload="startGame()">
<canvas id="canvas" width="720" height="480"></canvas>
</body>
</html>
HTML, Webseite, CSS, JavaScript, HTML5, Programmiersprache, Webentwicklung

Meistgelesene Beiträge zum Thema HTML5