8:00p EST / 7:00p CST / 5:00p PST
Links connect an HTML page to other pages in the same project or parent directory, or to external sites.
Links are created with the anchor or "a" tag:
<a></a>
Note: The <a>
should not be confused with the <link>
tag.
<a></a>
taghref
attribute: Destination where the link points to<a href="http://www.girldevelopit.com">Girl Develop It</a>
href
attribute can point to:
The default appearance of a link is underlined text.
The state
or status of a link also affects its appearance:
The link target is an optional attribute that tells the browser where to open the link.
<a href="home.html" target="_self">Link Text</a>
<a href="home.html" target="_blank">Link Text</a>
The anchor tag can be used to create links to specific parts of a page.
id
attribute to create and name a bookmark<h3 id="seasons">Season 1 Episodes</h3>
<a href="#seasons">Watch Season 1</a>
Add a few external links and bookmark links to your project page.
There are over 100 HTML elements:
List of HTML Elements (MDN)table, form, button,
header, footer, nav,
section, main, article,
video, figure, embed,
div, span, ...
Using HTML elements that give meaning to or describe the content of a page.
HTML elements that do not describe content or have any meaning.
<div>Watch Season 1</div>
<button>Watch Season 1</button>
Image source: SeekBrevit.com
Two common non-semantic elements:
div
: Often used as a generic container for grouping contentspan
: Often used as a generic wrapper to style inline content
<div>
<h2>Season 1</h2>
<h3>Episode 5</h3>
<p>While on a mission, Lorca is captured by the Klingons
and unexpectedly finds himself in the company of prisoner of war
Starfleet Lieutenant Ash Tyler and notorious criminal Harry Mudd.</p>
</div>
<p>Watch Season 1 and stay tuned for <span>Season 2</span></p>
Make writing semantic HTML your default practice
divs
div
can live inside a semantic parent element and be used to organize/group other children elementsdiv
can be made semantic by adding accessibility attributes such as role
or aria
propertiesNeed to call out important text?
Use semantic HTML elements:
heading tags (h1, h2, etc), strong, em
Otherwise, use CSS for visual or stylistic effects
Test Your Skills: HTML Accessibility (MDN)
Attempt the first exercise: "HTML Accessibility 1"
CSS is a "style sheet language" that lets us apply design and layout to content on an HTML page.
CSS syntax or rule consists of a selector and declarations of property-value pairs:
selector {
property: value;
property: value;
}
For example:
p {
color: yellow;
background-color: black;
}
Some HTML elements have default style, but CSS allows for added customization.
Without CSS, an HTML page is merely a page with text, images and links.
Inline CSS
Embedded or Internal CSS
External CSS Stylesheet
<p style="color:red">Some text.</p>
style
attribute.Add an inline color style to any element in your HTML document.
<head>
...
<style>
p {
color: blue;
font-size: 12px;
}
</style>
</head>
<head>
element<style>
tagUndo the inline style and make it an embedded style instead.
<head>
...
<link rel="stylesheet" href="style.css">
</head>
index.html
of your REPL project, copy the CSS declaration you created previously in the style
tags, and paste the code to the style.css
file in your REPL project folderstyle
block in the index.html
file