--- id: html-attributes title: "HTML Attributes" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["HTML attribute", "href", "src", "alt", "style attribute", "lang attribute", "title attribute", "name/value pair"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.90 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["html", "web", "frontend", "w3schools", "attributes"] raw_sources: ["https://www.w3schools.com/html/html_attributes.asp"] applied_in: [] github_commit: "" --- # [[HTML Attributes]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Attributes provide additional information about HTML elements; they are always specified in the start tag as name/value pairs like `name="value"`. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **All elements can have attributes** β€” they give additional information about an element. [S1] - **Always in the start tag** β€” attributes are written inside the opening tag. [S1] - **Name/value pairs** β€” usually written as `name="value"`. [S1] - **`href`** β€” on ``, specifies the URL the link goes to. [S1] - **`src`** β€” on ``, specifies the path to the image; can be an absolute URL (external) or a relative URL (internal). [S1] - **`width` / `height`** β€” on ``, provide size information in pixels. [S1] - **`alt`** β€” on ``, provides alternate text shown if the image cannot be displayed, and used by screen readers. [S1] - **`style`** β€” adds styling such as color, font, size to an element. [S1] - **`lang`** β€” on ``, declares the language of the page (aids search engines and browsers). [S1] - **`title`** β€” defines extra info about an element, shown as a tooltip on mouseover. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Lowercase attribute names** β€” W3C recommends lowercase; W3Schools demands it. [S1] - **Quote the values** β€” W3C recommends quoting; required when the value contains spaces. [S1] - **Single vs. double quotes** β€” when a value itself contains double quotes, wrap it in single quotes (and vice-versa). [S1] - **Relative over absolute `src`** β€” relative URLs are preferable because they won't break if the domain changes. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) HTML attributes provide additional information about HTML elements. All HTML elements can have attributes; attributes are always specified in the start tag and usually come in name/value pairs like `name="value"`. [S1] **The href Attribute** The `` tag defines a hyperlink. The `href` attribute specifies the URL of the page the link goes to: [S1] ```html Visit W3Schools ``` **The src Attribute** The `` tag is used to embed an image. The `src` attribute specifies the path to the image to be displayed: [S1] ```html ``` There are two ways to specify the URL in the `src` attribute. An **absolute URL** links to an external image hosted on another website. An **relative URL** links to an image hosted within the website; here the URL does not include the domain name. It is almost always best to use relative URLs β€” they will not break if you change domain. [S1] **The width and height Attributes** The `` tag should also contain the `width` and `height` attributes, which specify the width and height of the image (in pixels): [S1] ```html ``` **The alt Attribute** The required `alt` attribute for `` specifies an alternate text for an image, if the image for some reason cannot be displayed. This can be due to a slow connection, an error in the `src` attribute, or if the user uses a screen reader: [S1] ```html Girl with a jacket ``` If a browser cannot find an image, it will display the value of the `alt` attribute: [S1] ```html Girl with a jacket ``` **The style Attribute** The `style` attribute is used to add styles to an element, such as color, font, size, and more: [S1] ```html

This is a red paragraph.

``` **The lang Attribute** You should always include the `lang` attribute inside the `` tag, to declare the language of the Web page. This is meant to assist search engines and browsers: [S1] ```html ... ``` Country codes can also be added to the language code in the `lang` attribute. The first two characters define the language; the last two define the country. For example "en-US" means English in the United States: [S1] ```html ... ``` **The title Attribute** The `title` attribute defines some extra information about an element. The value of the `title` attribute will be displayed as a tooltip when you mouse over the element: [S1] ```html

This is a paragraph.

``` **Single or Double Quotes?** Double quotes around attribute values are the most common, but single quotes can also be used. In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes: [S1] ```html

``` Or the opposite: [S1] ```html

``` **Chapter Summary** - All HTML elements can have **attributes**. [S1] - The `href` attribute of `` specifies the URL of the page the link goes to. [S1] - The `src` attribute of `` specifies the path to the image to be displayed. [S1] - The `width` and `height` attributes of `` provide size information for images. [S1] - The `alt` attribute of `` provides an alternate text for an image. [S1] - The `style` attribute is used to add styles to an element, such as color, font, size, and more. [S1] - The `lang` attribute of the `` tag declares the language of the Web page. [S1] - The `title` attribute defines some extra information about an element. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The `href`, `src`, `alt`, `width`, `height`, `style`, `lang`, and `title` examples above are the everyday attributes applied to links, images, and text on real pages. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Link with href (HTML): ```html Visit W3Schools ``` Image with src, alt, width, height: ```html Girl with a jacket ``` Declaring page language: ```html ``` Inline style and tooltip: ```html

This is a red paragraph.

``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) HTML does not strictly require lowercase attribute names or quoted values, but the W3C recommends both (and quoting is mandatory when a value contains spaces). The source advises preferring relative `src` URLs over absolute ones for resilience to domain changes. [S1] ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[HTML Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[HTML Elements]], [[HTML Basic]], [[HTML Styles]], [[HTML Introduction]] - **μ°Έμ‘° λ§₯락:** Referenced whenever configuring an element's behavior, source, language, accessibility text, or inline styling. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” HTML Attributes β€” https://www.w3schools.com/html/html_attributes.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "HTML Attributes" page (Astra wiki-curation, P-Reinforce v3.1 format).