Web Development 1

HTML

Basic HTML Boilerplate

viewport -> visable area for webpage
keywords -> define the keyword of the webpage, search engine optimization
description -> define a discription of webpage content
The better we can represent structure of document use HTML, the better search engines can read and understand our content.

Heading and Text

h1 -> main heading, only 1 h1 every page
h2 -> subheading, can have multiple h2 every page
...
em -> italicize

eg:
<h1><em>Fashion Trends</em></h1>
<h2 id="trendsIntro">Trends</h2>
<h3 id="column1-1">Quiet Luxury</h3>

Entities

&lt; => <
&gt; => >
&copy; -> copyright symbol

eg:
<p>&copy; 2025 Fashion Trends. All rights reserved.</p>

Hyperlink

a -> anchor element

eg:
<a href="index.html">Home</a>
link to section in the same page -> eg: <a href="#about">About Us</a>
link to section in another page -> eg: <a href="index.html#column1-1">Quiet Luxury</a>
the link jump to top -> eg: <a href="#">Jump to top</a>
link to email -> eg: <a href="mailto:b.xiajia.10@student.scu.edu.au">Contact Us</a>

Images and Video

img -> image element
src -> source of the image
alt -> alternative text when image cannot be displayed

eg: <img class="colorImg" src="images/quietLuxuryColors.png" alt="Quiet Luxury Color Palette">

video -> video element
loop -> video will play automatically again and again
muted -> video is muted by default (eg:when not muted, video can not autoplay in some browser like Chrome)
Provide a fallback text if the browser does not support the video element

eg:
<video autoplay loop muted src="./homepage.mp4" >
Your browser does not support videos.
</video >

Lists

ul -> show items where the order doesn't matter
li -> list item

eg:
<ul>
<li><a href="index.html">Home</a></li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">Trends</a>
<div class="dropdown-content">
<a href="#column1-1">Quiet Luxury</a>
<a href="#column1-2">New Retro Glam</a>
<a href="#column1-3">Balletcore</a>
</div>
</li>
<li class="dropdown"><a href="javascript:void(0)" class="dropbtn">Dress Code</a>
<div class="dropdown-content">
<a href="#column2-1">Business Casual</a>
<a href="#column2-2">Smart Casual</a>
<a href="#column2-3">Business Formal</a>
</div>
</li>
<li><a href="webdev1.html">Webdev 1</a></li>
<li><a href="#about">About Us</a></li>
<li><a href="mailto:b.xiajia.10@student.scu.edu.au">Contact Us</a></li>
</ul>

list-style-type -> default is disc for ul
ol -> ordered list
dl -> description list

Navigation

nav ->navigation element

eg:
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li class="dropdown">
<a href="javascript:void(0)" class="dropbtn">Trends</a>
<div class="dropdown-content">
<a href="#column1-1">Quiet Luxury</a>
<a href="#column1-2">New Retro Glam</a>
<a href="#column1-3">Balletcore</a>
</div>
</li>
<li class="dropdown"><a href="javascript:void(0)" class="dropbtn">Dress Code</a>
<div class="dropdown-content">
<a href="#column2-1">Business Casual</a>
<a href="#column2-2">Smart Casual</a>
<a href="#column2-3">Business Formal</a>
</div>
</li>
<li><a href="webdev1.html">Webdev 1</a></li>
<li><a href="#about">About Us</a></li>
<li><a href="mailto:b.xiajia.10@student.scu.edu.au">Contact Us</a></li>
</ul>
</nav>

Section

section -> classify related content together

eg:
<section>
<h2>About Us</h2>
<div id="about"><p class="introduction">Fashion Trends is a curated style guide designed to help users understand contemporary fashion movements and dress codes with clarity and confidence. Our website breaks down key trends such as Quiet Luxury, New Retro Glam, and Balletcore by highlighting their defining aesthetics, color palettes, and essential items. We aim to make fashion more accessible by presenting each style in a structured and visually engaging way, allowing visitors to explore trends at their own pace. In addition to trend overviews, we provide explanations of common dress codes to support users in choosing appropriate outfits for both professional and social settings. Through clean layouts, thoughtful descriptions, and easy navigation, Fashion Trends offers an informative and enjoyable experience for anyone looking to deepen their understanding of modern style.</p></div>
</section>

How To Create a Two Column Layout

div -> division element

eg:
<div class="row">
<div class="column">
<h2>Color Palette</h2>
<div id="colorPalette1" class="trends">
<img class="colorImg" src="../images/quietLuxuryColors.png" alt="Quiet Luxury Color Palette">
</div>

Termly

Termly is a website that can generate policy.

eg:
I used Termly to generate the Terms and Conditions for my website.

HTML Cleaner

HTML Cleaner is a tool which reduces a HTML document (or fragment) to basic HTML tags and attributes - clean HTML.

eg:
I used HTML Cleaner to clean the policy(HTML format) generated by Termly.

How To Create a Modal Box - HTML

A modal is a dialog box/popup window that is displayed on top of the current page.

eg:
<div id= "termsAndConditions"class="modal">
<div class="modalContent">
<h2>Terms and Conditions</h2>
<p>
Welcome to Fashion Trends! By accessing or using our website, you agree to comply with and be bound by the following terms and conditions. Please read them carefully before using our services.
</p>
<p>
You can read the full terms and conditions <a href="termsAndConditions.html"><strong><strong>here</strong></strong></a>.
</p>
<div>
<button class="modalButton" onclick="agreeToTermsAndConditions()">Agree</button>
</div>
</div>
</div>

How To Create a Form With Multiple Steps - HTML

eg:
<form id= "form1" action="">
<div class="tab"><h2 class="tab-title">Name*:</h2>
<p><input type="text" placeholder="First name..." oninput="this.className = ''"></p>
<p><input type="text" placeholder="Last name..." oninput="this.className = ''"></p>
</div>
<div class="tab"><h2 class="tab-title">Contact Infomation*:</h2>
<p><input type="text" placeholder="E-mail..." oninput="this.className = ''"></p>
<p><input type="text" placeholder="Phone..." oninput="this.className = ''"></p>
</div>
<div class="tab"><h2 class="tab-title">Message*:</h2>
<p><textarea placeholder="Write something.." oninput="this.className= ''"></textarea></p>
</div>
<br>
<div style="overflow:auto;">
<div style="float:right;">
<button class="formButton" type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
<button class="formButton" type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
</div>
</div>
<div class="step-all">
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
</div>
</form>

CSS

Types

inline CSS
internal CSS
external CSS
priority: inline > internal > external

Selectors

Type selector -> element name

eg: p, h1, div

Class selector -> .classname

eg: .colorImg

ID selector -> #idname

eg: #reference

Background Image Repeat

CSS background-repeat -> sets if/how a background image will be repeated. By default, a background-image is repeated both vertically and horizontally
CSS background-repeat Horizontally -> repeat-x
CSS background-repeat Vertically -> repeat-y
CSS background-repeat No Repeat -> no-repeat
CSS background-position -> is used to set the starting position of the background image. By default, a background-image is placed at the top-left corner of an element.

eg:
body{
background-image: url("../images/background.png");
background-size: 400px;
}

Horizontal Navigation Bar

flex -> modern way of creating a horizontal navigation bar

eg:
ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #6B6F3B;
display: flex;
justify-content: center;
top: 0;
width: 100%;
}
ul li a {
display: block;
color:#F2D091;
padding: 14px 16px;
text-decoration: none;
}
ul li a:hover {
background-color: #8E1A1A;
}

Dropdown Menu

eg:
.dropdown-content {
display: none;
position: absolute;
background-color: #6B6F3B;
min-width: 160px;
z-index: 1;
}
.dropdown-content a {
color: #F2D091;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {background-color: #8E1A1A}
.dropdown:hover .dropdown-content {
display: block;
border-radius: 10px;
}

Box Model

Box Model

Position

static -> all HTML elements are positioned static by default.
relative -> is positioned relative to its normal position in the document flow.
absolute -> is positioned relative to the nearest positioned ancestor (with position other than static).
fixed -> is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used set the final location of the element.
sticky -> A sticky element is positioned relative until a certain scroll position is reached - then it "sticks" in that place (like position:fixed).

How To Create a Two Column Layout

flex

eg:
.row {
display: flex;
}
.column {
flex: 50%;
}

Inline-block

eg:
.occasionsList{
text-align: left;
display: inline-block;
font-size: 25px;
list-style-type: disc;
width: 300px;
height: auto;
border-radius: 15px;
color:#F2D091;
padding: 30px;
}

How To Create a Modal Box - CSS

A modal is a dialog box/popup window that is displayed on top of the current page.

eg:
.modal {
display:none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
backdrop-filter: blur(5px);
background-color: rgba(0,0,0,0.4);
}
.modalContent{
background-color: #F2D091;
margin: 15% auto;
padding: 20px;
border: 1px solid #6B6F3B;
width: 80%;
color: #8E1A1A;
border-radius: 15px;
}
.modalButton{
margin-top: 20px;
cursor: pointer;
border-radius: 12px;
background-color: #8E1A1A;
color: #F2D091;
width: auto;
padding: 10px 20px;
}

CSS backdrop-filter Property

The backdrop-filter property is used to apply a graphical effect to the area behind an element.

Tip: To see the effect, the element or its background must be at least partially transparent.

eg:
.modal {
backdrop-filter: blur(5px);
background-color: rgba(0,0,0,0.4);
}

How To Create a Form With Multiple Steps - CSS

eg:
#form1 {
background-color: #6B6F3B;
margin: 100px auto;
padding: 40px;
width: 70%;
min-width: 300px;
border-radius: 15px;
border: 3px solid #F2D091;
}
.tab-title{
font-size: 30px;
font-weight: bold;
margin-bottom: 20px;
color:#F2D091
}
input {
padding: 10px;
width: 100%;
font-size: 17px;
border: 5px solid #F2D091;
border-radius: 10px;
}
textarea{
padding: 10px;
width: 100%;
font-size: 17px;
border: 5px solid #6B6F3B;
}
input.invalid {
background-color: #ffdddd;
}
textarea.invalid {
background-color: #ffdddd;
}
.tab {
display: none;
}
.formButton {
background-color: #8E1A1A;
color: #F2D091;
border: none;
padding: 10px 20px;
font-size: 17px;
cursor: pointer;
border-radius: 12px;
}
.step-all {
text-align: center;
margin-top: 40px;
}
.step {
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #8E1A1A;
border: none;
border-radius: 50%;
display: inline-block;
opacity: 0.5;
}
.step.active {
opacity: 1;
}
.step.finish {
background-color: #F2D091;
}

JavaScript

How To Create a Modal Box - JavaScript

A modal is a dialog box/popup window that is displayed on top of the current page.

eg:
function showTermsAndConditions() {
const alreadyAgreed = localStorage.getItem("alreadyAgreed");
if (alreadyAgreed === "true") {
return;
}
const content=document.getElementById("termsAndConditions");
content.style.display="block";
}
function agreeToTermsAndConditions() {
const content=document.getElementById("termsAndConditions");
content.style.display="none";
localStorage.setItem("alreadyAgreed", "true");
}
window.onload = showTermsAndConditions;

Window localStorage

The localStorage object allows you to save key/value pairs in the browser.

I used localStorage to make the Terms and Conditions modal just pop up once. After users click "Agree", the modal will not appears again, even if they back to the home page through navigation bar or open the website again.

Note:
The localStorage object stores data with no expiration date.

The data is not deleted when the browser is closed, and are available for future sessions.

eg:
function showTermsAndConditions() {
const alreadyAgreed = localStorage.getItem("alreadyAgreed");
if (alreadyAgreed === "true") {
return;
}
const content=document.getElementById("termsAndConditions");
content.style.display="block";
}
function agreeToTermsAndConditions() {
const content=document.getElementById("termsAndConditions");
content.style.display="none";
localStorage.setItem("alreadyAgreed", "true");
}
window.onload = showTermsAndConditions;

Window history.back()

The history.back() method loads the previous URL (page) in the history list.
The history.back() method only works if a previous page exists.

eg:
<button class="backButton" onclick="history.back()">Go Back</button>

How To Create a Form With Multiple Steps - JavaScript

eg:
var currentTab = 0;
showTab(currentTab);
function showTab(n) {
var x = document.getElementsByClassName("tab");
x[n].style.display = "block";
if (n == 0) {
document.getElementById("prevBtn").style.display = "none";
} else {
document.getElementById("prevBtn").style.display = "inline";
}
if (n == (x.length - 1)) {
document.getElementById("nextBtn").innerHTML = "Submit";
} else {
document.getElementById("nextBtn").innerHTML = "Next";
}
fixStepIndicator(n)
}
function nextPrev(n) {
var x = document.getElementsByClassName("tab");
if (n == 1 && !validateForm()) return false;
x[currentTab].style.display = "none";
currentTab = currentTab + n;
if (currentTab >= x.length) {
const successMessagee = document.getElementById("successModal");
successMessagee.style.display = "block";
document.getElementById("form1").style.display = "none";
return false;
}
showTab(currentTab);
}
function validateForm() {
var x, y, z, i, valid = true;
x = document.getElementsByClassName("tab");
y = x[currentTab].getElementsByTagName("input");
for (i = 0; i < y.length; i++) {
if (y[i].value == "") {
y[i].className += " invalid";
valid = false;
}
}
z = x[currentTab].getElementsByTagName("textarea");
for (i = 0; i < z.length; i++) {
if (z[i].value == "") {
z[i].className += " invalid";
valid = false;
}
}
if (valid) {
document.getElementsByClassName("step")[currentTab].className += " finish";
}
return valid;
}
function fixStepIndicator(n) {
var i, x = document.getElementsByClassName("step");
for (i = 0; i < x.length; i++) {
x[i].className = x[i].className.replace(" active", "");
}
x[n].className += " active";
}
function closeSuccessMessage(){
location.reload();
}

Window location.reload()

The reload() method reloads the current document.
The reload() method does the same as the reload button in your browser.

eg:
function closeSuccessMessage(){
location.reload();
}



Jump to top