1/10
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What are attributes?
provides additional information about elements.
What are the features of an attribute?
Has start tag
Comes in name-value pairs
Excludes little brackets (<>)
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>
Explain src attribute.
(Source)
specifies path to image that is to be displayed.
Used with <img> tag
e.g. <img src="img_girl.jpg">
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.
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">
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">
style Attribute
Adds styles to an element.
colour, font, size, etc.
e.g. <p style="">This is a red paragraph.</p>
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>
title Attribute
Defines extra information about an element.
Value of title attribute is displayed as a tooltip when mouse over the element
What is preferred when writing attributes?
Quotes
lowercase