It is going to be long but i try to be brief.
Nel is the fusion between in + il=nel
Nello is the fusion between in + lo =nello
Now i take two words where the article is different:
(il) ristorante: 95% of cases, masculine words have "il" as article because it ends in o.Ristorante is one of the few exceptions but fortunately portuguese can help and save most of the time to recongize the gender of each noun.Another example, il libro.
(lo) specchio: in few % of cases, masculine words have "lo" has article despite it ends in o, however, this kind of words usually start with some combination of some letters (like in this case) "sp".You don't have to worry much of these irregular nouns where there aren't many.
So, if i have to say no restaurante, no livro -> nel ristorante, nel libro
No espelho-> nello specchio
And this pattern is the same for aother articles and prepositions like:
Sobre: sul (su+il), sullo (su+lo)
Sul ristorante, sul libro
Com: col (con+ il), con lo
Com o restaurante (i know that seems quite weird, but is just to explain the difference) col ristorante, col libro
Com o espelho-> con lo specchio
If you have troubles, try to look at the ending of the word and it should be much more clear.
Try to watch this layer on this page: https://en.wikibooks.org/wiki/Italian/Prepositions
The only thing i have ho say is about the line con: nowadays they are not used anymore "colla, colle coi, cogli" but con la, con le, con i, con gli the only one still used is col.