I’m making a school project about a webpage and mine’s about videogame news, analysis, articles etc.
I want the body of the article to be centered with a max width of 600px. So far I could work around this using a fieldset, but when I add the images, wether it is on top of the text to ilustrate the new or if I want to add another in between is when everything messes up and I don’t know what to do
So far, this is all I’ve got:
<!DOCTYPE html>
<html>
<head>
<title>ALEXGUIAS</title>
<style type="text/css">
body {font-family: Verdana, Geneva, Tahoma, sans-serif;
background-color: #54545C;
color:rgb(180, 220, 255)
}
header {
border-color: rgb(255, 196, 0);
border-radius: 10px;
box-shadow: 0px 0px 5px 5px rgb(255, 196, 0);
color: rgb(255, 196, 0);
text-align: center;
padding: 20px 0;
font-style: italic;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-weight: 700;
}
nav li {display: inline;
padding: 25px;
}
a.class1 {
color: rgb(255, 196, 0);
}
a.class1:link {
text-decoration: none;
color: rgb(255, 196, 0);
}
a.class1:visited {
text-decoration: none;
color: rgb(255, 196, 0);
}
a.class1:hover {
text-decoration: underline;
color: rgb(255, 196, 0);
}
a.class1:active {
text-decoration: none;
color: rgb(255, 196, 0);
}
fieldset {
padding-top: 10px;
margin: auto;
border: none;
max-width: 600px;
height: auto;
}
h1 {
margin: auto;
padding: 20px;
text-align: center;
max-width: 600px;
overflow: hidden;
}
img {
margin-left: auto;
margin-right: auto;
display: inline;
}
</style>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="PaginaPrincipal2.html" target="blank" class="class1"><img src="LOGO.png" height="15%" width="15%"></img></a></li>
<li><a href="Noticias.html" target="blank" class="class1">NOTICIAS</a></li>
<li><a href="Analisis.html" target="blank" class="class1">ANÁLISIS</a></li>
<li><a href="Articulos.html" target="blank" class="class1">ARTÍCULOS</a></li>
<li><a href="Guias.html" target="blank" class="class1">GUÍAS</a></li>
<li><a href="Lanzamientos.html" target="blank" class="class1">PRÓXIMAMENTE</a></li>
<li><a href="Apoyanos.html" target="blank" class="class1">APÓYANOS</a></li>
<li><a href="Usuario.html" target="blank" class="class1">ENTRAR/CREAR CUENTA</a></li>
</ul>
</nav>
</header>
<h1>Una filtración asegura que el próximo Call of Duty saldrá en Xbox Game Pass</h1>
<img src="COD.jpg" height="30%" width="30%">
<fieldset>
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<img src="COD.jpg" height="25%" width="25%">
</fieldset>
</body>
</html>
2
Answers
Based on your description, I assume this is what you are looking for:
Just add
to your body tag’s staying in css.
It will make the whole body appear as a flexbox and, as it’s direction is set to column. it will take it’s contents and put them vertically.
align-items will align everything (including the image) to the center.
whole code,