HTML, CSS & JS, lesson 2
Plain text gets you far, but the web is built on links, and most pages need images and lists too.
Some elements need extra information. You give it with attributes inside the opening tag,
written as name="value":
<a> is an anchor, the element for links. Its href attribute is where the link goes.
The text between the tags is what people click, so make it describe the destination. "Click
here" tells nobody anything.
<img> has no closing tag because it has no content. src is the image file, and alt
describes the image for people who can't see it (screen readers, slow connections, broken
links). Every meaningful image needs a useful alt. A purely decorative image gets .
2 exercises to try what you just read.
alt=""HTML has two common lists:
<ul>, an unordered list, for items where order doesn't matter (shown with bullets).<ol>, an ordered list, for steps or rankings (shown with numbers).Inside either one, each item is an <li>:
Lists can nest: put a whole <ul> inside an <li> to make a sub-list.
Make an unordered list with exactly three items: Flour, Milk and Eggs, in that order.
Then, below it, add an ordered list with at least two steps of your choice.
Add:
Pancake science that points to https://en.wikipedia.org/wiki/Pancake.src="https://picsum.photos/320/200" and an alt text of at least 10 characters
that describes it.<a href="https://developer.mozilla.org">Read the MDN docs</a><img src="pancakes.jpg" alt="A stack of pancakes with berries on top"><ol>
<li>Whisk the eggs.</li>
<li>Add the milk.</li>
</ol>