03:00
BAA1028 - Workflow & Data Management
A web server handles your DNS requests for a website, does background processing and retrieval (e.g. from databases), finds .html
,.css
, .js
files, plus images, fonts, audio etc., then serves it all to your browser using http.
A ‘client’—usually a web browser—receives files from the server using using http and displays the pages you requested by rendering the HTML, applying CSS styles to the HTML elements, and reading (parsing) JavaScript code.
Network
and Reload the pageSee, all the documents downloaded to display the page!
03:00
In order to really fine-tune the appearance of our site, we need to dive a bit into the world of HTML and CSS.
HTML (Hypertext Markup Language) is a markup language1 that tells web browsers how to structure web pages. You can think of HTML as the skeleton of a web page. It gives authors the means to create elements like headings, text, tables, lists, add media, etc.
Source: Adapted from Nicolas Karasiak
1Markdown is also a lightweight markup languages – it is a bit easier for humans to write and read than HTML. HTML is more expressive and allows for customization that is difficult or impossible to do in Markdown.
CSS (Cascading Style Sheets) is a programming language that allows you to control how HTML elements look on a web page. You can think of CSS as the outfit that is styling the skeleton. It allows authors to control aspects such as the colors, layout, and font style.
Source: Adapted from Nicolas Karasiak
Your browser will style HTML documents using an internal style sheet, which ensures that headings are larger than normal text, links are highlighted, lists and tables are structured correctly, etc.
CSS allows website developers to add additional styling to web browser defaults. Otherwise, websites would be pretty boring to look at (and they’d all generally look the same).
An HTML file (HyperText Markup Language file) is a plain text document used to create and structure the content of a web page.
It contains the essential code that browsers interpret to display text, images, links, videos, and other elements on a webpage.
The file typically has a .html
or .htm
extension.
In essence, an HTML file serves as the backbone of a website, working in tandem with CSS (Cascading Style Sheets) for design and JavaScript for functionality to deliver a complete web experience.
HTML provides the basic structure of a webpage, defining elements such as headings, paragraphs, links, lists, and multimedia content.
HTML uses tags (e.g., <h1>
, <p>
, <img>
, <a>
) to organise and label different sections and types of content, making it clear how they should appear and behave.
It can link to external resources such as CSS files for styling, JavaScript files for interactivity, and multimedia assets like images or videos.
HTML is used to create navigational structures, such as menus and hyperlinks, enabling users to move between pages on the site or to external resources.
Modern HTML includes semantic tags (e.g., <header>
, <article>
, <footer>
) that provide additional meaning and improve accessibility and search engine optimisation (SEO).
Right-click on the webpage in your browser and select “View Page Source” (name may vary by browser). Then, copy the source code displayed, open Notepad/TextEdit, and paste it in to view or edit.
e.g., Spyder, JupyterLab, Jupyter Notebook, PyCharm, VS Code, Neovim, …
Version control (e.g., Git) works well (efficient, differences between versions are easy to understand) with plain text documents, .docx
et al. not so much
Future proof
Can easily manipulated with external tools
…
Canonical reference: The Plain Person’s Guide to Plain Text Social Science by Kieran Healy
https://damien-dupre.github.io/my-first-web-page.html
Display the source code
List the different HTML tags
05:00
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body bgcolor="#BBCCFF">
<h1>Welcome to my first webpage</h1>
<p>I hope you will like this page.</p>
</body>
</html>
All HTML documents must start with a document type declaration: <!DOCTYPE html>
.
The HTML document itself begins with <html>
and ends with </html>
.
The visible part of the HTML document is between <body>
and </body>
.
Learn more: https://www.w3schools.com/html/html_basic.asp
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body bgcolor="#BBCCFF">
<h1>Welcome to my first webpage</h1>
<p>I hope you will like this page.</p>
</body>
</html>
Go to https://jsfiddle.net/, paste it in the HTML box, and Click the RUN button
Change the text and observe your changes with the RUN button
05:00
Write a piece of text for each of the following pages:
Find pictures of yourself or that represents you to be published online and view by recruiters.
An HTML5 document consists of 4 core elements:
doctype
, html
, head
, and body
All websites have the following fundamental structure!
Sometimes you will see the term utf-8
in the HTML code, it is the encoding
See here for more details on (character) encoding?
See also here
My only rule: Use utf-8
Content is between matching pairs of HTML tags:
Some tags don’t need ‘closing’ e.g. the img
tag:
The only other ‘self-closing’ tags you might use are:
A hyperlink goes to another page, a separate website,
or can jump to a specific section on the same page,
marked by an HTML id
attribute:
⚠️ IMPORTANT SLIDE !!
most HTML tags are nested inside other HTML tags: (watch your indentation!)
You can add HTML comments in your code:
<!-- The figure tag is for image/captions boxes -->
<figure>
<!-- The img tag goes here -->
<!-- The figcaption tag goes here -->
</figure>
Text between <!--
and -->
won’t show on screen.
My slides are using a Fira Font type, which makes the ligature between corresponding signs but <!--
and -->
are actually < ! - -
and - - >
without the spaces.
Elements comprise start tags and end tags that render some form of content in a particular way.
The basic anatomy of an HTML element:
Browse a complete list of HTML tags.
Tag | What it does |
---|---|
<div></div> |
defines a division or section in an HTML document |
<h1></h1> |
create a first-level heading (largest) |
<h6></h6> |
create a sixth-level heading (smallest) |
<p></p> |
begin a new paragraph |
<strong></strong> |
bold text |
<em></em> |
italicized text |
<img></img> |
present an image |
<a></a> |
define a hyperlink |
<br> |
add a line break (empty element) |
<span></span> |
an inline container used to markup part of a text or document |
Note: Some HTML elements have no content (e.g. the <br>
, or “break” element) – these are called empty elements and do not have an end tag.
Remember to close out tags from the inside-out to avoid unexpected renderings.
Nested HTML elements:
IMPORTANT: Take extra care to never skip (or incorrectly type) an end tag! Some elements will still display correctly if you forget an end tag, but you cannot rely on this. Forgotten end tags will cause you headaches as you try troubleshoot unexpected results and errors.
If you spot any errors in this cheat sheet, please contact us – info@websitesetup.org
about.html
in the docs
folderThen open this page on your web browser!
Note: Use TextEdit (MacOS) / Notepad (Win) to open and modify the html code. In the TextEdit app on your Mac, choose TextEdit > Settings, then click Open and Save. Select “Display HTML files as HTML code instead of formatted text”.
05:00
CSS is a rule-based language, meaning that it allows you to define groups of styles that should be applied to particular elements or groups of elements on a web page.
For example, “I want all level one (<h1>
) headings to be green text with a bit of extra space between each letter” could be coded as:
Selectorsselect the HTML element(s) you want to style (e.g. level one headings, <h1>
)
Declarations sit inside curly brackets, {}
, and are made up of property and value pairs. Each pair specifies the property of the HTML element(s) you’re selecting (e.g. the color property of the element <h1>
), and a value you’d like to assign to that property (e.g. green)
A property and its corresponding value are separated by a colon, :
. Declarations end with a semicolon, ;
A CSS rule inside {}
can contain multiple CSS declarations:
main {
margin: 10px; /* 10 pixels all round */
width: 80%; /* always 80% of the screen width */
background: #eee;
font-family: Tahoma, Helvetica, sans-serif;
}
or be on one line (harder to read when developing):
There are many different CSS selector types, but the following will get you pretty far (though you can learn more about all the different categories of CSS selectors here).
Element selectors: selects all HTML elements with the specified element name
Grouping selectors: selects all HTML elements with the same style definitions
ID selectors: uses the id attribute of an HTML element to select a specific element; id of an element is unique within a page, so the id selector is used to select one unique element
Class selectors: selects HTML elements with a specific class attribute
Universal selector: selects all HTML elements on the page
Inline styling: (not a selector type, but an alternative way to apply CSS styling)
Any HTML element can be used as a selector. The declarations specified apply to all HTML elements of that type.
Group multiple element selectors together (separated by commas) if you want them all styled the same way.
Attributes provide extra information about elements. They are always specified in the start tag and usually come in value/name pairs (e.g. attributeName="attributeValue"
). We can use attributes (e.g. the class
attribute) to apply targeted styling using class selectors.
A class selector uses the class
attribute of an HTML element to style that specific element. Class selectors are written using a .
followed by the selector name, e.g. .selector
. HTML elements can have more than one class, e.g. <p class="class1 class2">
CSS
HTML
<p class="blue-italicized">My first paragraph is styled</p>
<p>But my second paragraph is not</p>
<p>We can use span tags to target <span class="blue-italicized">parts of an element</span> as well</p>
An ID selector uses the id
attribute of an HTML element to style that specific element. IDs must be unique within a page and therefore can only be used to select and style one unique element. ID selectors are written using a #
followed by the selector name, e.g. #selector
.
CSS
HTML
The universal selector selects all HTML elements on the page. It is written using only an asterisk, *
.
CSS
HTML
<h1>My level one header will be styled</h1>
<h2>This level two header will be styled</h2>
<p>This paragaph will also be styled</p>
You may define styles directly inline using the style
attribute. However, it’s best practice to use these sparingly as it mixes content (HTML) with presentation (CSS) and cannot be reused with other elements like defined CSS rules can.
HTML with inline styling
<p>This is a normal paragraph</p>
<p style="color: red; font-style: italic;">This paragraph has inline styling</p>
<p>Here, only the word <span style="color: red; font-style: italic;">paragraph</span> is styled</p>
the selector is the element to be styled:
⚠️ IMPORTANT SLIDE !!
IDs should always be unique! (CSS #NameOfID)
IDs are often used to identify things in JavaScript
classes can be applied to multiple tags (CSS .NameofClass)
Classes are often used to style similar things in CSS
It is often the case that more than one CSS rule will point to the same element. For example, say you have a style sheet and HTML that look like the following:
CSS
HTML
<h1>This is my header</h1>
<p>This is my paragraph with <span style="green-text">some green text</span></p>
In this case, we have a universal selector that styles all of our text orange, but we also have an element selector that colors our <h1>
elements blue and a class selector that is applied inline to color a subset of text green. How do you know which style will be declared and applied to each of our HTML elements?
Specificity can be complicated (especially when you consider all the other types of selectors we haven’t covered in these slides). For the purposes of this workshop and getting started on your CSS journeys, a general rule of thumb is as follows: Inline styles are the most specific and will override ID selectors, which will override class selectors, which will override element selectors, etc. The order that rules are written in your stylesheet matters as well – since rules are read top to bottom, a directly competing rule farther down your stylesheet will take precedent.
Inline Styles
IDs
Class Selectors
Element Selectors
Universal Selectors
the stylesheet needs to be linked in the head
section
technically, it can go between style
tags directly in the head
section, but it should really go into an external file
⚠️ IMPORTANT SLIDE !!
.html
files (<
angle brackets>
).css
files ({
curly braces}
)⚠️ IMPORTANT SLIDE !!
images
folder!Huge thanks the following people who have generated and shared most of the content of this lecture:
Fania Raczinski: Web Design & Development
Sam Csik: Customizing Quarto Websites
Go to https://html5up.net/.
Download the template of your choice for free.
Fill the template with your informations and observe the changes on your local computer.
Notes: This will not be accepted as a submission to the module’s assignment but you will be able to use the content created in your future Quarto website. However, we will use it next week in our lecture about GitHub.
20:00
Thanks for your attention and don’t hesitate to ask if you have any questions!
@damien_dupre
@damien-dupre
https://damien-dupre.github.io
damien.dupre@dcu.ie