-
Notifications
You must be signed in to change notification settings - Fork 0
LLC: Webmaking with HTML and CSS
Jonathan edited this page Jun 20, 2023
·
19 revisions
- Slides: https://bit.ly/llc-html2 (Google Slides)
- Learner reference: https://bit.ly/llc-html2-refs 👈 YOU ARE HERE
- Development environment & starter project: https://bit.ly/llc-html2-ide (CodeSandbox.io)
- HTML language reference (👇 below)
- CSS language reference (👇 below)
- Exercise instructions (to follow along):
- HTML is made of elements.
- Elements are created using tags.
-
Tags use angle brackets, e.g.
<h1> ... </h1>and usually (though not always) come in pairs, which are put at the start and end of the content they contain<p> Content goes here </p>.- An element's start and end tags share the name of the element however the end tag has a forward slash to distinguish it from the start tag, e.g.
<strong>and</strong>.
- An element's start and end tags share the name of the element however the end tag has a forward slash to distinguish it from the start tag, e.g.
-
Most elements can (and often do) contain other elements, e.g. a
mainelement containing asectionelement:
<main>
<section>
Some section content here
</section>
</main><a href="https://canadalearningcode.ca">Visit Canada Learning Code's website to find out about us</a>- Used to create clickable links on a page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!-- page content -->
</body>
</html>- Elements that should be included on every web page.
<body>
<!-- web page content to be displayed goes in here -->
</body>- All the elements contained within this element are displayed when a web page loads, as opposed to elements inside the
headelement which aren't displayed.
<!DOCTYPE html>- Needs to be the absolute first thing in an HTML document.
- Identifies the rest of the document (web page) as following the HTML standard, which helps browsers to properly display the document.
- See basic elements.
<em></em><head>
<!-- head content, like scripts or style sheets, goes here -->
</head>- Not to be confused with headings or the
headerelement, theheadelement contains extra information for a web page, such as links to scripts and external style sheets. - No element in
headis displayed on a web page per se, though elements in head (likestyle) can affect how other web page elements are styled or displayed. - See basic elements.
<h1>Web page title<h1>
<h2>Section 1 heading or title</h2>
<h3>Section 1 subheading A</h3>
<h3>Section 1 subheading B</h3>
<h2>Section 2 heading or title</h2>
<h3>Section 2 subheading A </h3>- 6 levels,
h1toh6. -
h1is the highest-level (most important) heading and there should only ever be one per page.
<html>
... web page content goes here ...
</html>-
htmlis the root element of the web page, containing all other HTML elements that are part of that web page. - See basic elements.
See the entry for unordered list and list items
<main>
Main web page content goes in here!
</main>-
mainis a sectioning element used to contain/indicate the main or central content on a web page. - There should only be one
mainelement per web page and its typically a direct child of thebodyelement.
<mark></mark><p>Here is some web page text.</p>- Despite its name, used to contain any amount of regular page text.
<section>
This section is about topic A.
</section>
<section>
This section is about topic B.
</section>-
sectionis a sectioning element used to separate and group web page content into related sections.
<small></small>*See entry for side comment.
<p>The strong element can be used to <strong>really emphasize</strong> important text.</p>-
strongis a content element that is, by default, equivalent to applying bold styling to the text contained within it.
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>- Combination of
ulandlielements -
<ul> ... </ul>container for the items in the list. -
<li> ... </li>element for each list item. - Unordered list = bulleted list (a numbered list uses the ordered
olelement)
selector { property: value; }Patterns that are used to refer to specific elements on a web page.
-
element type selector— the name of the element type, e.g.
section(to select all sections).
section { /* ... */ }
p { /* ... */ }-
class selector— a dot
.followed by the name of a class, e.g..big(to select all elements with thebigclass). Classes are added to elements using theclassHTML attribute, e.g.,<p class="big"> ... </p>(a paragraph element with thebigclass).
.big { /* ... */ }
.dark { /* ... */ }-
descendant selector— an expression made of two or more selectors separated by a space
. Matches elements of the second (or later) selector that are contained within the first (or earlier) selectors, e.g.,h1 em(selects allemelements that are contained in anh1element).
h1 em { /* ... */ }
main section { /* ... */ }-
background-color— The background color of an element. -
color— The color of text inside an element. -
display— (Advanced) Determines the way that an element is placed/laid out relative to other elements.blockelements are stacked on top of each other, whereasinlineelements are placed side-by-side. For a much deeper explanation, see MDN Web Docs - display (external) and MDN Web Docs - Block and inline layout in normal flow (external). -
font-size— The size of text when displayed in this element. The defaultfont-sizefor most browsers is16px. Supports many different units for its value, most often as percentages (e.g.,150%), pixels (e.g.,16px), or ems (e.g.,1.5em). -
font-family— The typeface used when displaying text in this element. -
line-height— The vertical space for a line of text. Can be relative to font-size (e.g.,1.1,1.5em,115%) or absolute (e.g.,18px). -
margin— The space (gap) between elements. Typically inpxorem. -
max-width— The maximum horizontal width an element is allowed to expand to, i.e., it can be smaller than this value, but not larger. -
padding— The space between the contents of an element and the border or edge of that element. -
text-align— Text justification, typicallyleft,right, orcenter. -
text-transform— Changes the case or capitalization of the characters that are contained in this element, when they're being displayed (this is purely a cosmetic change, i.e. it doesn't affect the underlying HTML content). -
width— Sets the horizontal width of an element. Note: if this is an absolute value (e.g.,700px), the element will not shrink when the window becomes too narrow (seemax-widthinstead). Can be a percentage (e.g., 85%), in which case the element will change size to maintain that percentage.
-
Some colours can be specified by name, e.g.,
background-color: red; -
Note that the color name is not enclosed in quotes, i.e., it is
redand not'red'. -
Select named colours, some of which are used in the starter project, include:
darkslategraygoldgoldenrodhotpinklightcyanlightgraylightgreenmediumvioletredskybluewhitewhitesmokeyellowgreen
-
A full list of named colours can be found in the MDN Web Docs References - <named-color> (External link)
MDN Web Docs References - rgb()
- Colours can be specified using an expression,
rgb(R, G, B)orrgb(R G B)where each ofR,G, andBrefer to the amount of red, green, and blue present in a colour. -
R,G, andBcan be written in one of three ways:- as a
number, between0%and255. e.g.rgb(31 120 50)(dark green) - as a
percentage, between0and100%, e.g.rgb(30% 20% 50%)(purple) - using the keyword
none
- as a
- All of the values must be of the same type (i.e., all numbers or all percentages) or
none