- HTML Attributes HTML Шинж чанарууд
- The href Attribute href шинж чанар
- The src Attribute src шинж чанар
- The width and height Attributes Width болон height шинж чанарууд
- The alt Attribute alt шинж чанар
- The style Attribute Style шинж чанар
- The lang Attribute lang шинж чанар
- The title Attribute Title Шинж чанар
- We Suggest: Always Use Lowercase Attributes Үргэлж жижиг үсэг ашиглаж байгаарай
- Single or Double Quotes?
- Chapter Summary
HTML attributes provide additional information about HTML elements.
HTML шинж чанарууд нь бүгд HTML элементийн талаарх нэмэлт мэдээлэл агуулдаг.
HTML Attributes HTML Шинж чанарууд #
- All HTML elements can have attributes Бүх HTML элементүүд нь өөрийн гэсэн шинж чанаруудтай байдаг
- Attributes provide additional information about elements HTML шинж чанарууд нь бүгд HTML элементийн талаарх нэмэлт мэдээлэл агуулдаг.
- Attributes are always specified in the start tag шинж чанарууд үргэлж эхлэлийн тэмдэгээр тодорхойлогддог
- Attributes usually come in name/value pairs like: name=”value” шинж чанарууд ихэвчлэн нэр/утга гэсэг хослолоор ажилдаг жишээ нь:Нэр=”утга”
The href Attribute href шинж чанар #
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to:
<a href="Apprentice.mn">Visit W3Schools</a> The src Attribute src шинж чанар #
The tag is used to embed an image in an HTML page. The src attribute specifies the path to the image to be displayed: нь HTML хуудасруу зураг нэгтгэхэд ашиглдаг.src шинж чанар нь харуулах зургийн замыг зааж өгдөг.
<img src="img_girl.jpg"> There are two ways to specify the URL in the src attribute:
src шинж чанар дотор URL-ийг тодотгох 2 арга байдаг.
1. Absolute URL – Links to an external image that is hosted on another website. Example: 1. Бүтэн URL – Өөр вэбсайт дээр байрлуулсан зургийн холбоосууд. Жишээ:"https//apprentice.mn:/images/img_girl.jpg".
2. Relative URL – Links to an image that is hosted within the website. Here, the URL does not include the domain name. If the URL begins without a slash, it will be relative to the current page. Example: src=”img_girl.jpg”. If the URL begins with a slash, it will be relative to the domain. Example: src=”/images/img_girl.jpg”.Харьцангуй URL – Вэбсайт дотор байрлуулсан зургийн холбоосууд. Энд URL нь домэйн нэрийг оруулаагүй болно. Хэрэв URL нь налуу зураасгүйгээр эхэлбэл энэ нь тухайн хуудастай хамааралтай байх болно. Жишээ: src = “img_girl.jpg”. Хэрэв URL нь налуу зураасаар эхэлбэл энэ нь домэйнтэй хамааралтай байх болно. Жишээ: src = “/ images / img_girl.jpg”.
The width and height Attributes Width болон height шинж чанарууд #
The <img> tag should also contain the width and height attributes, which specifies the width and height of the image (in pixels):
<img> нь width болон height гэсэн шинж чанаруудыг агуулах хэрэгтэй байдаг.Энэ нь зургийн өргөн болон өндөрийг тохируулдаг(пиксэлээр хэмжигдэнэ.)<img src="img_girl.jpg" width="500" height="600"> The alt Attribute alt шинж чанар #
The required alt attribute for the tag specifies an alternate text for an image, if the image for some reason cannot be displayed. This can be due to slow connection, or an error in the src attribute, or if the user uses a screen reader.
тэмдэгт дотор байрлах alt нь зураг ямар нэгэн байдалаар харагдахгүй болсон тохиолдолд зурагний оронд байрлах тэкст юм.Удаан интернет ,алдаатай srcшинж чанар эсвэл дэлгэц уншигч ашиглаж байгаагаас болж зураг гаргахгүй байх шалтгаалан болдог.
<img src="img_girl.jpg" alt="Girl with a jacket"> Огт байдаггүй зургийг гаргах гэж оролдоцгооё
<img src="img_typo.jpg" alt="Girl with a jacket"> The style Attribute Style шинж чанар #
The style attribute is used to add styles to an element, such as color, font, size, and more.
style шинж чанар нь элементэд өнгө,хэмжээ,фонт гэх мэт хэв маяг нэмэхэд хэргэлэгдэнэ.
<p style="color:red;">This is a red paragraph.</p> The lang Attribute lang шинж чанар #
You should always include the lang attribute inside the <html> tag, to declare the language of the Web page. This is meant to assist search engines and browsers.
The following example specifies English as the language:
<html>тэмдэг дотор үргэлж lang шинж чанарыг бичих ёстой.Ингэснээр веб хуудас ямар хэл дээр харагдахыг заралдаг бөгөөд энэ нь хайлтын систем болон вебд туслах зорилготой
<!DOCTYPE html>
<html lang="en">
<body>
...
</body>
</html> Country codes can also be added to the language code in the lang attribute. So, the first two characters define the language of the HTML page, and the last two characters define the country.
The following example specifies English as the language and United States as the country:
Улсын кодууд lang -т нэмэгдэн бичэгдэж болдог.Эхний 2 үсэг ямар хэл гэдгийг тодорхойлох бол дараагийн 2 үсэг аль улсых гэдгийг тодорхойлно.
<!DOCTYPE html>
<html lang="en-US">
<body>
...
</body>
</html> The title Attribute Title Шинж чанар #
The title attribute defines some extra information about an element.title шинж чанар нь элементийн хэдэн илүү мэдээлэлийг тодорхойлно.
The value of the title attribute will be displayed as a tooltip when you mouse over the element:Title-ийн утга нь title элемент дээр mouse-аараа заахад гарч ирэх болно.
<p title="I'm a tooltip">This is a paragraph.</p> We Suggest: Always Use Lowercase Attributes Үргэлж жижиг үсэг ашиглаж байгаарай #
The HTML standard does not require lowercase attribute names.
The title attribute (and all other attributes) can be written with uppercase or lowercase like title or TITLE.
However, Apprentice recommends lowercase attributes in HTML, and demands lowercase attributes for stricter document types like XHTML.
HTML стандарт нь шинж чанаруудын үсэг жижиг байхыг шаарддаггүй.
Гарчигны шинж чанар (болон бусад бүх шинж чанарууд) нь title эсвэл TITLE шиг том жижиг үсгээр бичиж болно.
Гэсэн хэдий ч бид сурагчид та бүхэндээ шинж чанараа жижиг үсэгээр бичихийг санал болгож байна. XHTML гэх мэт хатуу баримт бичэглэлийн төрлүүдэд шинж чанараа жижиг үсгээр бичэхийг шаарддаг.
Сайн:
<a href="https://apprentice.mn/docs-category/html/">Visit our HTML tutorial</a> Муу:
<a href=https:https://apprentice.mn/docs-category/html/>Visit our HTML tutorial</a> Single or Double Quotes? #
Double quotes around attribute values are the most common in HTML, but single quotes can also be used.
хоёр зартиг (” “) энэ нь HTML-дахь шинж чанарын утгын гадуур хамгийн түгээмэл ашиглагддаг гэсэн ч нэг зартиг ( ‘ ‘ ) бас ашиглагдана.
In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes: Зарим нэг тохиолдолд шинж чанарын утга нь өөрөө хоёр зартигтай байвал нэг зартиг ашиглах хэрэгтэй.
<p title='John "ShotGun" Nelson'> Эсвэл эсрэгээрээ:
<p title="John 'ShotGun' Nelson">
Chapter Summary #
- All HTML elements can have attributes Бүх HTML элементүүд шинж чанартай байж болно
- The
hrefattribute of<a>specifies the URL of the page the link goes tohrefийн<a>нь хуудасруу очих URL ийн холбоосыг хэлнэ - The
srcattribute of<img>specifies the path to the image to be displayed<img>-ийнsrcшинж чанар нь харуулах зургийн замыг зааж өгдөг - The
widthandheightattributes of<img>provide size information for images<img>шинж чанарынwidthболонheightнь зурагын өндөр болон өргөнийг тодорхойлно - The
altattribute of<img>provides an alternate text for an image<img>тэмдэгийнaltшинж чанар нь зураг гарахгүй тохиолдолд үзүүлэх текст юм. - The
styleattribute is used to add styles to an element, such as color, font, size, and morestyleшинж чанар нь элементэд өнгө,фонт болон хэмжээ гэх мэт хэв маягуудыг оруулдаг. - The
langattribute of the<html>tag declares the language of the Web pagelangшинж чанар нь<htmlийг веб хуудас дээр ямар хэлээр үзүүлэхийг тодорхойлно. - The
titleattribute defines some extra information about an elementtitleшинж чанар нь элементийн тухай илүү мэдээлэлийг илтгэнэ.