CSS AND HTML HELP

Status
This thread has been locked.

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0
Hello, Im trying to place my picture into the horizontal middle on my website. But it wont work with the css
here is index code
Code:
<head>
  <meta charset="utf-8">
  <img class="bild1" src="felix_2.jpg" alt="platon" style="width:30%;" />
  <title></title>
</head>
And css code
Code:
.bild1 {
  display: block;
  margin-left: auto;
  margin-right: auto;
}
https://gyazo.com/508dc715621629d8b0bc6fa155ef3f58
Looks like this ^^
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

ItzMarcus

Feedback score
1
Posts
43
Reactions
6
Resources
0
I believe you need to set a width on the element first. So maybe do "width: 100%", and remember to set a height on the parent element.

And why are you placing the picture in the head section? All your code should go into the body section.
 

FelixDev

Typical Developer and Designer
Premium
Feedback score
9
Posts
1,113
Reactions
331
Resources
0
I believe you need to set a width on the element first. So maybe do "width: 100%", and remember to set a height on the parent element.

And why are you placing the picture in the head section? All your code should go into the body section.
didnt wrok :/
 

Thunderbelly

<3
Premium
Feedback score
10
Posts
386
Reactions
122
Resources
0
Code:
<!DOCTYPE html>
<html>
<head>
<style>
img {
    display: block;
    margin-left: auto;
    margin-right: auto;
}
</style>
</head>
<body>
<img src="img.jpg style="width:40%">
</body>
</html>

should work
 
Status
This thread has been locked.
Top