{"id":38250,"date":"2025-08-22T14:59:20","date_gmt":"2025-08-22T17:59:20","guid":{"rendered":"https:\/\/www.locaweb.com.br\/ajuda\/?post_type=ht_kb&#038;p=38250"},"modified":"2025-08-22T14:59:20","modified_gmt":"2025-08-22T17:59:20","slug":"como-colocar-imagem-no-html","status":"publish","type":"ht_kb","link":"https:\/\/www.locaweb.com.br\/ajuda\/wiki\/como-colocar-imagem-no-html\/","title":{"rendered":"Como colocar imagem no HTML do seu site"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">As imagens s\u00e3o essenciais para tornar um site mais atrativo, visualmente informativo e f\u00e1cil de compreender. Elas ajudam a ilustrar conte\u00fados, destacar produtos e melhorar a experi\u00eancia de quem acessa a p\u00e1gina.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Por isso, saber <\/span><b>como colocar imagem no HTML do seu site<\/b><span style=\"font-weight: 400;\"> \u00e9 uma habilidade b\u00e1sica e indispens\u00e1vel para qualquer pessoa que cria p\u00e1ginas web.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Uso da tag &lt;img&gt;<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">A tag<\/span> <i><span style=\"font-weight: 400;\">&lt;img&gt;<\/span><\/i><span style=\"font-weight: 400;\"> \u00e9 utilizada no <\/span><a href=\"https:\/\/www.locaweb.com.br\/blog\/temas\/codigo-aberto\/html-guia-completo-sobre-a-principal-linguagem-da-internet\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">HTML<\/span><\/a><span style=\"font-weight: 400;\"> para inserir imagens em uma p\u00e1gina da web. Ela \u00e9 uma tag autoencerr\u00e1vel, ou seja, n\u00e3o possui uma tag de fechamento. Sua principal fun\u00e7\u00e3o \u00e9 <\/span><b>carregar e exibir uma imagem <\/b><span style=\"font-weight: 400;\">a partir de um caminho definido no atributo <\/span><i><span style=\"font-weight: 400;\">src<\/span><\/i><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Al\u00e9m disso, ela pode incluir outros atributos, como <\/span><i><span style=\"font-weight: 400;\">alt<\/span><\/i><span style=\"font-weight: 400;\">, <\/span><i><span style=\"font-weight: 400;\">width<\/span><\/i><span style=\"font-weight: 400;\">, <\/span><i><span style=\"font-weight: 400;\">height <\/span><\/i><span style=\"font-weight: 400;\">e<\/span> <i><span style=\"font-weight: 400;\">title<\/span><\/i><span style=\"font-weight: 400;\">. Usar a <\/span><i><span style=\"font-weight: 400;\">&lt;img&gt;<\/span><\/i><span style=\"font-weight: 400;\"> corretamente contribui para a acessibilidade, o SEO e a boa apresenta\u00e7\u00e3o visual do site.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Como inserir imagem localmente com o HTML img?<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Para inserir uma imagem local em HTML, \u00e9 necess\u00e1rio que o <\/span><b>arquivo da imagem esteja salvo na mesma pasta que o arquivo .html, ou em uma subpasta<\/b><span style=\"font-weight: 400;\"> acess\u00edvel. O atributo <\/span><i><span style=\"font-weight: 400;\">src <\/span><\/i><span style=\"font-weight: 400;\">indica o caminho da imagem.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Exemplo:<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;img src=\"foto-exemplo.jpg\" alt=\"Descri\u00e7\u00e3o da imagem\"&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">Se a imagem estiver em uma subpasta chamada <\/span><b>imagens<\/b><span style=\"font-weight: 400;\">, o caminho ser\u00e1:<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;img src=\"imagens\/foto-exemplo.jpg\" alt=\"Descri\u00e7\u00e3o da imagem\"&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">\u00c9 importante sempre<\/span><b> usar nomes de arquivos simples <\/b><span style=\"font-weight: 400;\">e evitar espa\u00e7os ou caracteres especiais para garantir que o navegador localize corretamente a imagem.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Como inserir imagem global por meio do HTML img?<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Tamb\u00e9m \u00e9 poss\u00edvel inserir imagens diretamente de links da internet, basta utilizar URLs no atributo <\/span><i><span style=\"font-weight: 400;\">src<\/span><\/i><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Exemplo:<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;img src=\"https:\/\/exemplo.com\/imagem.jpg\" alt=\"Descri\u00e7\u00e3o da imagem\"&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">Apesar de pr\u00e1tico, fazer isso exige aten\u00e7\u00e3o. Utilizar imagens hospedadas em outros sites pode causar <\/span><b>problemas de carregamento<\/b><span style=\"font-weight: 400;\">, caso o link mude ou saia do ar.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Al\u00e9m disso, o hotlinking (uso de imagens de outros servidores sem permiss\u00e3o)<\/span><b> pode violar direitos autorais ou sobrecarregar <\/b><span style=\"font-weight: 400;\">o servidor original.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Imagem flutuante<\/span><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-38251\" src=\"https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1.jpg\" alt=\"\" width=\"1627\" height=\"1175\" srcset=\"https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1.jpg 1627w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-300x217.jpg 300w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-1024x740.jpg 1024w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-768x555.jpg 768w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-50x36.jpg 50w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-1536x1109.jpg 1536w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-60x43.jpg 60w, https:\/\/www.locaweb.com.br\/ajuda\/wp-content\/uploads\/2025\/08\/image1-100x72.jpg 100w\" sizes=\"auto, (max-width: 1627px) 100vw, 1627px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Para alinhar uma imagem \u00e0 esquerda ou \u00e0 direita do conte\u00fado, utiliza-se a propriedade <\/span><a href=\"https:\/\/www.locaweb.com.br\/blog\/temas\/codigo-aberto\/css\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">CSS<\/span><\/a><span style=\"font-weight: 400;\"> float. Isso permite que <\/span><b>o texto se ajuste ao lado<\/b><span style=\"font-weight: 400;\"> da imagem.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Exemplo:<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;img src=\"foto.jpg\" alt=\"Descri\u00e7\u00e3o\" style=\"float: left; margin-right: 10px;\"&gt;<\/span><\/i>\r\n\r\n<i><span style=\"font-weight: 400;\">&lt;p&gt;Texto que se ajusta ao lado da imagem.&lt;\/p&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">O uso de <\/span><i><span style=\"font-weight: 400;\">float: right<\/span><\/i><span style=\"font-weight: 400;\"> tamb\u00e9m \u00e9 poss\u00edvel, e \u00e9 recomend\u00e1ve<\/span><b>l adicionar margens para evitar que o texto fique colado <\/b><span style=\"font-weight: 400;\">\u00e0 imagem. Essa t\u00e9cnica ajuda a melhorar o layout da p\u00e1gina.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Atributo alt e t\u00edtulo da imagem<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">O atributo<\/span> <span style=\"font-weight: 400;\">alt<\/span> <span style=\"font-weight: 400;\">(texto alternativo) \u00e9 fundamental para acessibilidade e SEO. Ele<\/span><b> descreve o conte\u00fado da imagem para tecnologias assistivas<\/b><span style=\"font-weight: 400;\">, como leitores de tela, e tamb\u00e9m \u00e9 exibido quando a imagem n\u00e3o pode ser carregada.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Motores de busca utilizam o alt para entender o contexto da imagem, o que contribui para o ranqueamento da p\u00e1gina.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Exemplo:<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;img src=\"logo-locaweb.png\" alt=\"Logo da empresa Locaweb\"&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">J\u00e1 o atributo title exibe um pequeno texto ao passar o mouse sobre a imagem e funciona como uma legenda informativa:<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;img src=\"produto.jpg\" alt=\"T\u00eanis esportivo azul\" title=\"Clique para ver mais detalhes\"&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">\u00c9 recomendado usar descri\u00e7\u00f5es objetivas e claras, sem repeti\u00e7\u00f5es entre alt e title.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Otimiza\u00e7\u00e3o de imagens para desempenho do site<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Imagens pesadas podem afetar diretamente o tempo de carregamento de um site, o que prejudica a experi\u00eancia de quem acessa e o posicionamento nos buscadores. Por isso, \u00e9 essencial otimizar cada imagem usada no HTML.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">T\u00e9cnicas como compress\u00e3o, uso de formatos adequados e carregamento sob demanda ajudam a manter a qualidade visual sem comprometer a performance da p\u00e1gina.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Compress\u00e3o de imagens<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Comprimir imagens significa<\/span><b> reduzir seu tamanho sem comprometer significativamente a qualidade<\/b><span style=\"font-weight: 400;\"> visual. Isso pode ser feito com ferramentas como TinyPNG, Squoosh ou Photoshop (por meio da op\u00e7\u00e3o Save for Web).\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A compress\u00e3o adequada<\/span><b> diminui o tempo de carregamento<\/b><span style=\"font-weight: 400;\"> da p\u00e1gina, especialmente em conex\u00f5es lentas. Antes de inserir qualquer imagem no HTML, \u00e9 recomend\u00e1vel otimiz\u00e1-la, principalmente se for exibida em destaque ou em \u00e1reas com muito tr\u00e1fego.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Uso do lazy loading<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">O atributo<\/span> <i><span style=\"font-weight: 400;\">loading=&#8221;lazy&#8221;<\/span><\/i><span style=\"font-weight: 400;\"> permite que as imagens sejam carregadas <\/span><b>apenas quando estiverem prestes a aparecer<\/b><span style=\"font-weight: 400;\"> na tela. Isso reduz o carregamento inicial da p\u00e1gina e melhora seu desempenho.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Exemplo:<\/span><\/p>\n<pre><i><span style=\"font-weight: 400;\">&lt;img src=\"foto.jpg\" alt=\"Descri\u00e7\u00e3o da imagem\" loading=\"lazy\"&gt;<\/span><\/i><\/pre>\n<p><span style=\"font-weight: 400;\">Essa t\u00e9cnica \u00e9 \u00fatil em p\u00e1ginas com muitas imagens ou rolagem longa, pois evita carregar conte\u00fado que a pessoa talvez nem veja.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">Escolha do formato adequado<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Escolher o formato certo para cada imagem ajuda a<\/span><b> equilibrar qualidade e tamanho<\/b><span style=\"font-weight: 400;\">. Cada formato tem caracter\u00edsticas e usos ideais, ent\u00e3o optar pelo tipo adequado evita arquivos desnecessariamente pesados e melhora a velocidade do site.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Veja um resumo dos principais formatos recomendados para web.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>JPEG<\/b><span style=\"font-weight: 400;\">: ideal para fotografias e imagens com muitos detalhes. Ele possui boa compress\u00e3o e mant\u00e9m qualidade visual razo\u00e1vel com tamanhos menores;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>PNG<\/b><span style=\"font-weight: 400;\">: indicado para imagens com transpar\u00eancia ou gr\u00e1ficos com poucas cores. Ele mant\u00e9m alta qualidade, mas gera arquivos maiores que JPEG;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>SVG<\/b><span style=\"font-weight: 400;\">: formato vetorial. Ele escala perfeitamente sem perda de qualidade, ideal para logotipos, \u00edcones e ilustra\u00e7\u00f5es simples;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>WebP<\/b><span style=\"font-weight: 400;\">: combina compress\u00e3o eficiente com boa qualidade. Ele \u00e9 uma excelente escolha para web, pois reduz o peso das imagens.<\/span><\/li>\n<\/ul>\n<h2><span style=\"font-weight: 400;\">Erros comuns ao inserir imagem no HTML<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Ao adicionar imagens no HTML, alguns erros s\u00e3o bastante frequentes e podem comprometer a exibi\u00e7\u00e3o correta do conte\u00fado.\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Caminho incorreto no <\/b><b><i>src<\/i><\/b><span style=\"font-weight: 400;\">: se o nome da imagem estiver errado ou o caminho estiver mal definido, a imagem n\u00e3o ser\u00e1 exibida. Verifique sempre se o arquivo est\u00e1 na pasta certa e se o nome est\u00e1 digitado corretamente \u2014 e n\u00e3o deixe de verificar tamb\u00e9m se a extens\u00e3o est\u00e1 certa;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Aspas ausentes ou mal utilizadas<\/b><span style=\"font-weight: 400;\">: sempre use aspas duplas ou simples ao definir o valor dos atributos, como <\/span><i><span style=\"font-weight: 400;\">src <\/span><\/i><span style=\"font-weight: 400;\">e <\/span><i><span style=\"font-weight: 400;\">alt<\/span><\/i><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Falta do atributo <\/b><b><i>alt<\/i><\/b><span style=\"font-weight: 400;\">: esquecer o <\/span><i><span style=\"font-weight: 400;\">alt <\/span><\/i><span style=\"font-weight: 400;\">prejudica a acessibilidade e o SEO da p\u00e1gina;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Links quebrados em imagens externas<\/b><span style=\"font-weight: 400;\">: ao usar URLs externas, certifique-se de que a imagem est\u00e1 dispon\u00edvel e acess\u00edvel;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Extens\u00e3o do arquivo errada ou incompat\u00edvel<\/b><span style=\"font-weight: 400;\">: HTML n\u00e3o reconhece formatos n\u00e3o suportados. Use JPEG, PNG, SVG ou WebP;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>N\u00e3o otimizar a imagem<\/b><span style=\"font-weight: 400;\">: inserir arquivos muito pesados compromete o desempenho.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Agora que voc\u00ea j\u00e1 sabe como colocar imagem no HTML do seu site, pode fazer isso frequentemente e de forma otimizada, para<\/span><b> criar p\u00e1ginas visuais, r\u00e1pidas e acess\u00edveis<\/b><span style=\"font-weight: 400;\">. Imagens bem inseridas fazem toda a diferen\u00e7a na <\/span><b>experi\u00eancia de quem navega<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Para construir um site com performance e seguran\u00e7a, conhe\u00e7a as solu\u00e7\u00f5es de <\/span><a href=\"https:\/\/www.locaweb.com.br\/hospedagem-de-sites-com-dominio-gratis\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">hospedagem de sites<\/span><\/a><span style=\"font-weight: 400;\"> da Locaweb. Temos tudo o que voc\u00ea precisa para publicar seu projeto na web com <\/span><b>estabilidade, suporte e tecnologia de ponta<\/b><span style=\"font-weight: 400;\">!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As imagens s\u00e3o essenciais para tornar um site mais atrativo, visualmente informativo e f\u00e1cil de compreender. Elas ajudam a ilustrar conte\u00fados, destacar produtos e melhorar a experi\u00eancia de quem acessa a p\u00e1gina.\u00a0 Por isso, saber como colocar imagem no HTML do seu site \u00e9 uma habilidade b\u00e1sica e indispens\u00e1vel para&#8230;<\/p>\n","protected":false},"author":48,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[119],"ht-kb-tag":[],"class_list":["post-38250","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-hospedagem-de-sites"],"_links":{"self":[{"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb\/38250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/users\/48"}],"replies":[{"embeddable":true,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/comments?post=38250"}],"version-history":[{"count":1,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb\/38250\/revisions"}],"predecessor-version":[{"id":38252,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb\/38250\/revisions\/38252"}],"wp:attachment":[{"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/media?parent=38250"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb-category?post=38250"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.locaweb.com.br\/ajuda\/wp-json\/wp\/v2\/ht-kb-tag?post=38250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}