You can do this with Javascript and a CSS selector like this:
document.querySelector('.conteudo p').style.display = 'block';
.conteudo p {
display: none;
}
<div class="conteudo">
<p>Primeiro parágrafo</p>
<p>Segundo parágrafo</p>
<p>Terceiro parágrafo</p>
</div>
Another way would be only with CSS so:
.conteudo p {
display: none;
}
.conteudo p:first-child {
display: block;
}
<div class="conteudo">
<p>Primeiro parágrafo</p>
<p>Segundo parágrafo</p>
<p>Terceiro parágrafo</p>
</div>
The second alternative may be the best seen avoid FOUC, if it is alternative to use CSS only.
The third alternative, only even with Javascript could be like this:
var els = document.querySelectorAll('.conteudo p');
for (var i = 0; i < els.length; i++) {
els[i].style.display = i == 0 ? 'block' : 'none';
}
<div class="conteudo">
<p>Primeiro parágrafo</p>
<p>Segundo parágrafo</p>
<p>Terceiro parágrafo</p>
</div>
Thanks Sergio, your solution is very good and useful. Thanks for the help
– Rafael S. Oiveira
It has how to simulate an FOUC... force the loading of images first for example ?
– MagicHat