HTML Attributes

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/10

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

11 Terms

1
New cards

What are attributes?

provides additional information about elements.

2
New cards

What are the features of an attribute?

Has start tag

Comes in name-value pairs

Excludes little brackets (<>)

3
New cards

what does the href attribute do?

Specify URL of page link.

  • Used with <a> tag.

  • e.g. <a href="Visit" data-prevent-progress="true">https://www.w3schools.com">Visit W3Schools</a>

4
New cards

Explain src attribute.

(Source)

specifies path to image that is to be displayed.

  • Used with <img> tag

  • e.g. <img src="img_girl.jpg">

5
New cards

What are two ways of speciying the URL path in src attribute? Which is better?

1 - Absolute URL

  • External website hosts image

  • You can not control whether image is removed or changed.

2 - Relative URL

  • Image hosted within your website

  • URL will not include domain name

  • If URL begins with slash it is relative to domain

    Otherwise, it is relative to current page.

Use relative URLs as they will not break if you change domain.

6
New cards

Width & Height Attributes?

Defines width and height of image (no. of pixels)

  • Should be used in <img> tag alongside src.

  • e.g. <img src="img_girl.jpg" width="500" height="600">

7
New cards

alt Attribute?

Displays alternate text for an image if it is not working, for example.

  • e.g. <img src="img_girl.jpg" alt="Girl with a jacket">

8
New cards

style Attribute

Adds styles to an element.

  • colour, font, size, etc.

  • e.g. <p style="">This is a red paragraph.</p>

9
New cards

lang Attribute

  • Declares language of web page.

  • Used in html tag.

    e.g.

    <!DOCTYPE html>
    <html lang="en">
    <body>
    ...
    </body>
    </html>

→ lang can also specify what country it is defined for.

<!DOCTYPE html>
<html lang="en-US">
<body>
...
</body>
</html>

10
New cards

title Attribute

  • Defines extra information about an element.

  • Value of title attribute is displayed as a tooltip when mouse over the element

11
New cards

What is preferred when writing attributes?

  • Quotes

  • lowercase