Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> HTML

Thuộc tính type của <area> trong HTML


Giới thiệu

Thuộc tính type của <area> (trong image map) chỉ định loại MIME (Multipurpose Internet Mail Extensions) của tài nguyên đích. Giúp trình duyệt hiểu trước nội dung sẽ tải.

Cú pháp

<area type="loai_media">

Ví dụ: image/png, image/jpeg, text/html, application/pdf.

Ví dụ minh họa

<!DOCTYPE html>
<html>
<body>
  <h2>Học tập</h2>
  <p>Học các công nghệ dễ dàng....</p>
  <img src="/images/usemap.gif" alt="usemap" border="0" usemap="#tutorials"/>
  <map name="tutorials">
    <area shape="poly" coords="74,0,113,29,98,72,52,72,38,27" href="/perl/index.htm" alt="Perl Tutorial" download="perl" hreflang="en"/>
    <area shape="rect" coords="22,83,126,125" alt="HTML Tutorial" href="/html/images/test.png" type="image/png" />
    <area shape="circle" coords="73,168,32" alt="PHP Tutorial" href="/php/index.htm" target="_blank" download="php" hreflang="en"/>
  </map>
</body>
</html>

Kết quả hiển thị

Khi nhấp vào vùng HTML (hình chữ nhật), trình duyệt biết trước đó là file PNG nhờ type="image/png".