htmlcssmargins

My margin code keep appearing on my site as text?


I'm new to coding and trying to do some test coding on my site before I dive head first into creating it, the problem that's been keeping me from continuing however is my margin code. It works but it keeps appearing in my text that's on my site as well as any other code I try. Is there any way I can fix this?

(code)

<!DOCTYPE html>
<html>
  <head>
<style>
body {
  background-image: url("starbackground.gif");
}
</style>
</head>

<body>
    <div id= "header">
    <meta charset="UTF-8">
    <title>Testing stuff</title>
   </div>
   
  <div id= tst>
    <p><h1 style="color:Tomato;">testing stuff rn</h1></p>
    </div>

   <div id = "textfortextbox"> 
   <p><h2 style="color:White;">text OooOooh</h2></p>
</div>

    <div id = "textbox">
     margin-left:100px;
<img src="https://starchips.neocities.org/text%20box.png" width="1200" height="1000" > 

</div>

</body>
</html>


Solution

  • Extending the solution of @Tangentially Perpendicular you could insert the div style inside the <style> marker:

    <style>
    body {
      background-image: url("starbackground.gif");
    }
    div[id="textbox"]{
    margin-left:100px;
    }
    </style>
    

    Or also:

    <style>
    body {
      background-image: url("starbackground.gif");
    }
    #textbox{
    margin-left:100px;
    }
    </style>