首页 > 其他分享 >HTML 16 - Images

HTML 16 - Images

时间:2024-05-18 16:07:29浏览次数:22  
标签:use 16 image height images HTML Images Image

HTML Images provides a visual content for web pages, enhancing user experiences and conveying information. They can be photographs, graphics, icons, or illustrations. To insert an image on HTML document we can use <img> tag.

Reason to use Images

HTML offers various elements for embedding, manipulating, and controlling images, contributing to the aesthetics and functionality of websites. Understanding image tags, attributes, and responsive design principles is essential for effective web development. We usually use images within hero section on the product page, it required src and alt attributes.

  • Increase Readbility: Using proper images/graphics can increase the readibility of our website, like what kind of products or services we provide.
  • SEO Impact: If we can use images with proper attributes that does not effect the loading time can be benificial to improve the website SEO.

There are lots of other advantages to use images we will know in this article.

Examples of HTML images

In the bellow examples we will see how to set the width, height, title, how to make image more attarctive on the webpage! and so many many other things on images.

You can use PNG, JPEG, or GIF image files based on your comfort but make sure you specify the correct image file name in src attribute. Using alt attribute is a good practice. it specifies an alternate text for an image if the image cannot be displayed.

Inserting an Image in HTML

You can insert any image in your web page by using <img> tag. The <img> tag is an empty tag, which means that, it can contain only list of attributes and it has no closing tag.

<DOCTYPE html>
   <html>
   <head>
      <title>Using Image in Webpage</title>
   </head>
   <body>
      <p>Simple Image Insert</p>
      <img src="logo.png" alt="Test Image" />
   </body>
   </html>

 

 

Importing images from another folder

Usually, we keep all the images in a separate directory. So let's keep HTML file test.htm in our home directory and create a subdirectory images inside the home directory where we will keep our image as test.png. Assuming our image location is "/html/images/test.png", try the following example.

<!DOCTYPE html>
<html>
<head>
   <title>Using Image in Webpage</title>
</head>
<body>
   <img src="/html/images/logo.jpg" alt="Test Image" />
</body>
</html>

 

Set Image Width and Height

You can set image width and height based on your requirement using width and height attributes. You can specify width and height of the image in terms of either pixels or percentage of its actual size.

<!DOCTYPE html>
<html>
<head>
   <title>Set Image Width and Height</title>
</head>
<body>
   <p>Setting image width and height</p>
   <img src="logo.jpg" alt="Test Image" width="450" height="200" />
</body>
</html>

 

Set Image Border

By default, image will have a border around it, you can specify border thickness in terms of pixels using border attribute. A thickness of 0 means, no border around the picture.

<!DOCTYPE html>
<html>
<head>
   <title>Set Image Width and Height</title>
</head>
<body>
   <p>Setting image width and height</p>
   <img src="logo.jpg" alt="Test Image"  alt="Test Image" border="3" />
</body>
</html>

 

Set Image Alignment

By default, image will align at the left side of the page, but you can use align attribute to set it in the center or right.

<!DOCTYPE html>
<html>
<head>
   <title>Set Image Width and Height</title>
</head>
<body>
   <p>Setting image width and height</p>
   <img src="logo.jpg"  alt="Test Image" border="3" align="right" />
</body>
</html>

 


 

标签:use,16,image,height,images,HTML,Images,Image
From: https://www.cnblogs.com/emanlee/p/18190426

相关文章

  • HTML 14 - CSS Classes
    InHTML,aclassisanattributethatcanbeappliedtooneormoreelementsandisusedtostyleandcategorizeelementsbasedoncommoncharacteristicsorpurpose.Classesallowsmultipleelementstosharethesamestylingrules.Byassigningthesamec......
  • HTML 13 - Style Sheet
     CSS,orCascadingStyleSheets,isatoolthatdefineshowwebdocumentslookonscreensorinprint.Sinceitsintroductionin1994,theW3Chasencouragedtheuseofstylesheetsforwebdesign.CSSletsyoucontrolthepresentationofyourcontent,w......
  • HTML 12 - Meta Tags
     HTMLletsyouspecifymetadata,whichisadditionalimportantinformationaboutadocument,inavarietyofways.TheMETAelementscanbeusedtoincludename/valuepairsdescribingpropertiesoftheHTMLdocument,suchasauthor,expirydate,alisto......
  • HTML 11 - Phrase Tags
     Thephrasetagshavebeendesignedforspecificpurposes,thoughtheyaredisplayedinasimilarwayasotherbasictagslike<b>,<i>,<pre>,and<tt>,asyouhaveseeninthepreviouschapter.Thischapterwilltakeyouthrough......
  • HTML 10 - Comments
    HTMLCommentsareusedtocommentinHTMLcodes,sothedevelopercanunderstandthepurposeofthatcodesectionanditishelpfullfordebuggingalso.Ifwearefacingsomeissuebecouseofanyparticularelementwecahcheckitbycommentingoutthate......
  • HTML 09 - Quotations
     QuotationsinHTMLallowyoutoincludeandformatquotedtextwithinyourwebcontent.HTMLprovidestagssuchas<blockquote>,<q>,<cite>,<address>,<bdo>and<abbr>tostructureandstylequotes.Thesetagshelp......
  • ASE160N08-ASEMI低压N沟道MOS管ASE160N08
    编辑:llASE160N08-ASEMI低压N沟道MOS管ASE160N08型号:ASE160N08品牌:ASEMI封装:TO-247批号:2024+沟道:N沟道导通内阻RDS(ON)Max:4.2mΩ启动电压:2V-4V最大漏源电流(Id):160A漏源击穿电压(VRM):80V安装方式:直插式封装正向电压:1.3V特性:低压N沟道MOS管产品引线数量:3产品内部芯片个数:2......
  • 力扣-316. 去除重复字母
    1.题目题目地址(316.去除重复字母-力扣(LeetCode))https://leetcode.cn/problems/remove-duplicate-letters/题目描述给你一个字符串s,请你去除字符串中重复的字母,使得每个字母只出现一次。需保证返回结果的字典序最小(要求不能打乱其他字符的相对位置)。 示例1:输入:s=......
  • CF1600~1700
    1731C\(a\)的质因子为奇数个,当且仅当\(a\)是平方数。我们考虑如何处理出有多少段的异或和为平方数。枚举平方数\(p\),枚举左端点\(l\),问题就变成了有多少\(r\)使得\(\oplus_l^ra_i=p\),处理出异或前缀和\(s_i=\oplus_1^ia_i\),查询有多少\(r\)使得\(s_r\opluss_{l-1}......
  • P1683 入门
    传送锚点:https://www.luogu.com.cn/problem/P1683题目描述不是任何人都可以进入桃花岛的,黄药师最讨厌像郭靖一样呆头呆脑的人。所以,他在桃花岛的唯一入口处修了一条小路,这条小路全部用正方形瓷砖铺设而成。有的瓷砖可以踩,我们认为是安全的,而有的瓷砖一踩上去就会有喷出要命的毒......