Last updated: 2020-10-10
Checks: 7 0
Knit directory: r4ds_book/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20200814)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version ae71e8e. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rproj.user/
Untracked files:
Untracked: VideoDecodeStats/
Untracked: analysis/images/
Untracked: code_snipp.txt
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/html_learnings.Rmd
) and HTML (docs/html_learnings.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | ceae495 | sciencificity | 2020-09-17 | Build site. |
Rmd | fd25a9a | sciencificity | 2020-09-17 | added html learnings |
html | b8fde7d | sciencificity | 2020-09-13 | Build site. |
Rmd | 4747fc8 | sciencificity | 2020-09-13 | added WIP html page |
html | 0bab89d | sciencificity | 2020-09-12 | Build site. |
Rmd | a47f1a3 | sciencificity | 2020-09-12 | completed ggplot exercises |
html | 720a89b | sciencificity | 2020-09-02 | Build site. |
html | 4612bb8 | sciencificity | 2020-09-02 | Build site. |
Rmd | 7305596 | sciencificity | 2020-09-02 | added new misc section |
The web was built to allow humans to share content even though our computers are different from each other.
This is made possible by 3 different programming languages each doing a part of the job.
HTML marks up the content of a site.
CSS stands for Cascading Style Sheets
JavaScript is a programming language that provides the ability to create more powerful interactivity.
There are 2
tags for bold
and 2
tags for italics
. But why?
Take the sentence:
My favourite show is Sesame Street.
favourite show
is emphasised here because it has a strong sentiment attached. Verbally emphasised <em>
tag here for emphasis italics
.Sesame Street
is however emphasised because it is the name of the show. Visually emphasised <i>
tag here for visual-only italics
.We’re conveying semantic meaning here, and these provide very different results for anyone listening to the content.
My <em>favourite</em> character from <i>Sesame Street</i> is Grover. gets translated as:
My favourite character from Sesame Street is Grover.
<strong>
suggests importance, urgency, or seriousness. Like the <em>
tag it conveys meaning, there is an alternative voice / mood here.<b>
tag is instead like the <i>
tag, it is used for visual emphasis. There isn’t a change in mood when using this tag.<h3><strong>WARNING!</strong> Do not be late.</h3> gets translated as:
<p>This is a paragraph of text. We want people to be able to scan it relatively quickly, but we also <b>want to mark certain sections with some boldness</b> so that it has some visual attention for the reader.</p> gets translated as:
This is a paragraph of text. We want people to be able to scan it relatively quickly, but we also want to mark certain sections with some boldness so that it has some visual attention for the reader.
There are 3 types of lists. We use lists on the web for things that don’t even look like lists - e.g. Navigation bars is a list of links. Lists can be used to markup navigation. While lists are normally used to present content, their structured and nestable semantics also make them good for navigation menus.
<li>
stands for list item
<ul>
stands for unordered list and we wrap the entire list of items in this tag to mark where the list starts and where it ends.
<ol>
stands for ordered list, and we use this for steps in a recipe for example. 1, then 2, then 3 etc.
<dl>
is used for kind of key-value pairs where we have an item / term and then we have a description for that term.
<dt>
is used for the term<dd>
is used for the definition / decription of the term.<br> <ul> <li>flour</li> <li>sugar</li> <li>baking soda</li> <li>vanilla essence</li> <li>2 eggs</li> </ul> <br>
Gets translated as:
<ol> <li>Mix the dry ingredients.</li> <li>In a separate bowl mix the eggs and the vanilla essence.</li> </ol> <br>
Gets translated as:
<dl> <dt>Unordered list</dt> <dd>For grouping a collection of items that do not have numerical ordering. Their order in the list is meaningless.</dd> <dt>Ordered list</dt> <dd>For an ordered list of items, typically rendered as a numbered list. Here order is meaningful.</dd> <dt>Definition list</dt> <dd>For creating a group of terms and descriptions.</dd> </dl> <br>
Gets translated as:
Let’s turn this paragraph into a quote:
We’ve gone from having 21 elements in HTML tags, that first document, to having 100 more elements now, and yet it’s still the same language. I find that amazing. It’s still the same language that was created 25 years ago. It’s grown an extra 100 elements in there, and yet it’s still the same language. — Jeremy Keith
<p>
tags because it’s a paragraph.<cite>
.<blockquote>
to indent it nicely.<q>
around the quote.<blockquote> <p> We’ve gone from having 21 elements in HTML tags, that first document, to having 100 more elements now, and yet it’s still the same language. I find that amazing. It’s still the same language that was created 25 years ago. It’s grown an extra 100 elements in there, and yet it’s still the same language. </p> <cite>— Jeremy Keith</cite> </blockquote>
Gets translated as:
We’ve gone from having 21 elements in HTML tags, that first document, to having 100 more elements now, and yet it’s still the same language. I find that amazing. It’s still the same language that was created 25 years ago. It’s grown an extra 100 elements in there, and yet it’s still the same language.
— Jeremy Keith
<p>Jeremy Keith said, <q>You could open an HTML document from back then in a browser today.</q></p>
Gets translated as:
Jeremy Keith said, You could open an HTML document from back then in a browser today.
There are some HTML that is meant to be inline
. They’re meant to be wrapped around phrases of content that is inline with other content. Goes inside bigger things.
<q>
<strong>
<b>
<i>
<em>
These are HTML elements that start a new block. These are the bigger things.
<blockquote>
<p>
<ol>
, <ul>
, <dl>
<time>
element.<elementname attributename="">
e.g. here <time datetime="2025-05-08">
as an example.<time datetime = "">
attribute needs to be in a specific format.<time datetime="2021-10-05">
<time datetime="20:15">
<time datetime="15:45-05:00">
which means 3:45pm in the TZ that is -5 hours from GMT (UTC).<time datetime="2021-11-04 15:45-05:00>
, with or without a T in between [<time datetime="2021-11-04T15:45-05:00>
]<time datetime=“2021-05-08”>on the 8th of May next year</time> renders as
<code>
to make a bit of text styling change.In the below text <code>{color:green;}</code> will change that part of the text.
We can write {color:green;}
in our CSS, and it will apply to anything marked up as an <H4>
element.
<
sign instead of having it be interpreted. We can do this by using the <
entity.>
we use >
.<pre>
keeps the formatting as you specified.<sub>
for subscript.<sup>
for superscript.H2O looks wrong like this.
<p>H<sub>2</sub>O looks wrong like this.</p>
If we use the <sub>
tag we get:
H2O looks correct now.
<p>Something that has a footnote<sup>2</sup>
Something that has a footnote2
The <pre>
element is used for listings where line breaks and other white space need to be preserved, while <code>
is more for short snippets inside of other content.
is for subscripts, like numbers in chemical formulas, and is for superscripts, like footnote markers.
Some attributes only work on certain elements e.g. datetime
only used with time
tag
Other attributes work on several elements.
And yet others are global attributes and may be applied to any HTML element.
class
: Gives us a way to attach a reusable name to any element. Then we can target all elements with that class in our CSS or JavaScript. It allows us to name certain elements and refer to them in other parts of our code.
<p class ="intro">
This is the introduction
</p>
id
: Similar to class
but we’re only allowed to use unique names once in an entire HTML page. We can use an ID for targeting CSS or JavaScript for a unique element with that id
, but because it is so specific most of the times developers stick to class
. It is particularly useful to target with JS or a targeted link. It also allows us to name certain elements and refer to them in other parts of our code.
<p class ="intro" id="article-intro">
This is the introduction
</p>
contenteditable
: Let’s a user do things. Here contenteditable = true
allows a visitor to a page to edit the contents. When the visitor does change something it doesn’t last (e.g. refreshing the browser will change it back to the original). That’s because HTML allows you to edit the content but more work is needed to capture and save the content the user enters.
<blockquote contenteditable="true">
Edit this content to add your own quote.
</blockquote>
Edit this content to add your own quote.
lang
and dir
: lang
tells the browser what language the content is in.
<p lang="en-GB"> We say colour, and visualisation when using British english :) </p> <p lang="fr"> Nous disons couleur et visualisation lors de l'utilisation de l'anglais britannique :) </p> <p dir="ltr"> In english the paragraph flows from left to right. </p> <p dir="rtl"> في اللغة العربية تتدفق الفقرة من اليمين إلى اليسار. </p>
ARIA roles are another type of attribute that can be added to any HTML element to give it more meaning and to ensure the browser understands what something is. Ideally we won’t need an ARIA role, if we use the right elements we’ll communicate the right message about the semantics of the content.
Sometimes we make compromises in our markup and then we need to be cognisant of people using our site, especially people with a disability - we want our site to be accessible by all people.
ARIA roles are HTML attributes that provide accessible info about that specific element. It tells screen readers, braille displays, magnifiers and other assistive technology things they need to know to make a site fully accessible.
ARIA is used to clarify to the accessibility tree what is happening with a particular element, set of elements, or interface. If something is broken, ARIA can be a way to fix it.
Jen built the above webpage that says “Hello World” but due to the targeted CSS each letter is in its own text box. The experience for a person using a screen reader will be particularly bad (have a look at the Accessibility window in the inspector to see the issue). Instead of saying “Hello World” it will say “H” “E” “L” “L” “O” “W” “O” “R” “L” “D”.
<h1> <div class="grid"> <span>H</span> <span>e</span> <span>l</span> <span>l</span> <span>o</span> <span>w</span> <span>o</span> <span>r</span> <span>l</span> <span>d</span> </div> </h1>
She fixed it by adding an ARIA role to the headline so that a screen reader can read “Hello World”, and then she hid the individual letters by setting aria-hidden="true"
which hides that element and all its children from the accessibility tree. It’s still in the DOM tree.
We want the headline to be seen by the Accessibility tree, but we don’t want the individual letters to be seen and read by the Accessibility tree. Hence wrap all the spans in a div and add the aria-hidden="true"
on the div.
<h1 aria-label="Hello World"> <div class="grid" aria-hidden="true"> <span>H</span> <span>e</span> <span>l</span> <span>l</span> <span>o</span> <span>w</span> <span>o</span> <span>r</span> <span>l</span> <span>d</span> </div> </h1>
<!--
and -->
tags e.g.
<!--This is a comment and will be ignored-->
<
: <>
: >&
: &©
: the copyright symbol ©™
: the trademark symbol ™☆
: the star symbol ☆
: insert a non-breaking space (usually the browser views any space) as a place it can wrap text. This tells the browser - hey, don’t break here.To make a link we use the <a>
element as in <a href="https://link-ref.co.za"></a>
which stands for anchor. On the opening tag we need an href="link address"
to tell the browser where we want it to go. href stands for HyperText reference.
The href
can have:
Absolute URL which includes http://
or https://
.
Links into other parts of your site can have absolute path.
On the same site - we can use relative URL because it is easier for testing etc.
To use relative path to things in our own site we need to understand the structure of our folders.
Imagine we have our images in its own folder. We can access an image through either:
/images/logo.gif
: Start at root and go to images and get the gif.../images/logo.gif
: From where we are go up to the folder I am in, then go up again. Ok, now go to images and get the gif.Everytime a browser is given a URL that points to go to a folder e.g. https://myawesomeweb.co.za/team/
the browser automatically looks for and loads index.html
. index.html
is a special file and makes it so we can have different folders with an index.html
file in each of them.
All of these will link to the same place:
<li><a href="/people/index.html">People</a></li> <li><a href="/people/">People</a></li> <li><a href="/people">People</a></li>
<img
tag.src
which is source attribute tells the browser which image to display.alt
attribute describes the picture and acts as a substitute when the image can’t be seen. It also helps for people who have visual disabilities to understand what the picture is showing. Blind people may use a screen reader that reads the alt text aloud to them.width
and height
attributes tell the browser the size of the picture in pixels. This allows the browser to have a headstart in defining the layout of the page. Otherwise the browser first has to load the image and then needs to figure out how big it must be. If we tell the browser these element sizes that helps with the rendering of the page.When you want the image to be shown to be different depending on the screen the user is using you can wrap the data in an <picture>
tag with a <srcset>
.
The <picture>
element gives you the flexibility you need to change content as well as image size. The srcset attribute lets the browser choose from options that fit the specific situation, minimizing bandwidth consumption while producing attractive results.
<picture> <source media="(min-width:600px)" srcset = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/10558/dog-960.jpg"> <source srcset = https://s3-us-west-2.amazonaws.com/s.cdpn.io/10558/dog-480.jpg> <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/10558/dog-480.jpg" alt="shiny black dog looking pensive" width="480" height="360"> </picture>
<audio></audio>
element to put audio on a page.<img>
use the src
attribute to provide the link to the file e.g. src="file.mp3"
.controls
attribute to tell the browser that we’d like it to provide some controls such as volume, play btn etc.<audio controls src="some_file.format" loop></audio>
<audio controls src="some_file.format" loop autoplay></audio>
<audio controls src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/10558/birds.mp3"> </audio>
<audio controls> <source src="http://example.com/birds.ogg" type="audio/ogg; codec=opus"> <source src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/10558/birds.mp3" type="audio/mpeg"> Sorry your browser doesn't not support audio. </audio>
<video></video>
element to put video on a page.<img>
use the src
attribute to provide the link to the file e.g. src="file.mp4"
.controls
attribute to tell the browser that we’d like it to provide some controls such as volume, play btn etc.<video controls src="xxx.mp4"> </video>
<source>
in video as well.srcset
attribute for video though.<video></video>
tag.Enable privacy-enhanced mode.
does not allow the video to be displayed in Rmd<div>
and <span>
elements.<div>
: block level element.<span>
: inline element.<!doctype html>
element right at the top of our page.<html></html>
tags around our entire content e.g. <html dir="ltr" lang="en-us">
. Remember that dir=
tells the browser which direction the text flows, and lang=
tells the browser what language your page is in.charset=
) goes in the <head></head>
element.title
in head: is not content, but rather is what shows up on the browser tab, or the bookmarked site name.meta name="viewport"
: Tells the browser that content has been morphed to fit smaller screens (i.e. it is a responsive website).meta name="description"
: Is what shows up in search engine results.link rel="stylesheet" href="main.css"
: Tells the browser where to link to for other assets we want to load like CSS files, fonts, favicons etc. rel
tells the browser what type of asset it is. href
provides the URL to the asset.<script src="my-js-file.js"></script>
: Tells the browser to load a JS file. This is often put at the end of the document instead of in the head so that the JS is loaded last.<head> <title>An Important Title :)</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="A description that'll show up on search engines results."> <link rel="stylesheet" href="css/S11-02.css"> </head>
<main>
element wraps around the main content of the page. Only used once per page.<header>
and <footer>
elements are used to mark content that is a header or footer. <header>
is used usually for logo, site name etc.<footer>
element does not have to go at the bottom of the page - it is used to convey additional info - hey, we have a few extra things to say about this.<article>
is wrapped around things like a blog post, or it may even be a short snip. It could be used for teaser cards. It’s semantic meaning is hey this by itself is a unit of content.<section>
is for sections of content. If we have a long essay for example with different sub-headlines we may have sections around segments of them. We may also have zones on our website. It’s semantic meaning is hey let’s just start with another thing.<aside>
: used to markup something that is off to the side, content that is not the main attraction. Its semantic meaning is hey, this thing is useful but not the main attraction.Check out Chapter 9 here.
Element | Name | Purpose | Attributes |
---|---|---|---|
<table> </table> |
Table | Wraps the whole table | |
<tr></tr> |
TR - table row |
Wraps around a set of elements, defining them as belonging to the same row |
colspan, rowspan, headers |
<th></th> |
TH - table header |
Defines a header for a column |
colspan, rowspan, scope |
<td></td> |
TD - table data |
Marks the actual bits of data |
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_South Africa.1252 LC_CTYPE=English_South Africa.1252
[3] LC_MONETARY=English_South Africa.1252 LC_NUMERIC=C
[5] LC_TIME=English_South Africa.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 rprojroot_1.3-2 digest_0.6.25 later_1.0.0
[5] R6_2.4.1 backports_1.1.6 git2r_0.26.1 magrittr_1.5
[9] evaluate_0.14 stringi_1.4.6 rlang_0.4.7 fs_1.4.1
[13] promises_1.1.0 whisker_0.4 rmarkdown_2.1 tools_3.6.3
[17] stringr_1.4.0 glue_1.4.1 httpuv_1.5.2 xfun_0.13
[21] yaml_2.2.1 compiler_3.6.3 htmltools_0.5.0 knitr_1.28