C779 - Web Development Foundations
This class provided me with the opportunity to significantly expand my website. I seized the chance to not only learn about CSS and HTML, but also JavaScript. As a result, I implemented substantial updates to the site, which is why you may have noticed that all the pages were updated on March 5th.
Last updated: May 4th, 2023
Web Dev Fundamentals
CSS and Graphics
Specificity
CSS specificity is the set of rules that determine which CSS styles are applied to an HTML element when multiple CSS rules are targeting the same element with conflicting styles.
CSS specificity is based on the number and type of selectors used in a CSS rule. Specificity is calculated by assigning a weight to each selector and then combining the weights to determine which rule takes precedence. The order of precedence in CSS specificity is:
- Inline styles - Styles that are applied directly to an HTML element using the style attribute.
- ID selectors - Selectors that target an HTML element by its ID attribute.
- Class selectors, attribute selectors, and pseudo-classes - Selectors that target an HTML element by its class attribute, attribute values, or state (such as :hover).
- Element selectors and pseudo-elements
- Selectors that target HTML elements by
their tag name or by a specific part of
an element (such as ::before and
::after).
If two or more CSS rules have the same level of specificity, then the rule that appears last in the CSS document will take precedence.
Inheritance
Is the ability of child elements to inherit CSS styles from their parent elements. This means that if a style is applied to a parent element, all of its child elements will inherit that style by default. For example, if a font size is set on the body element, all text inside the body will inherit that font size unless a more specific style is applied to override it.
Cascading
Is the process by which styles are applied to HTML elements based on their specificity and order in the CSS document. When there are conflicting styles targeting the same element, the style with the highest specificity takes precedence. If two styles have the same specificity, the style that appears last in the CSS document will take precedence.
!important rule
overrides other styles, even if they have higher specificity
SASS
SASS helps to make writing and managing CSS more efficient and scalable, allowing developers to write cleaner, more organized, and maintainable code. Some of the key features of SASS include:
- Variables: Allows developers to store and reuse values throughout their stylesheets.
- Nesting: Provides a way to write more organized and readable styles by nesting selectors within one another.
- Mixins: Allows developers to define and reuse sets of CSS declarations across their stylesheets.
- Inheritance: Provides a way to create a hierarchical relationship between CSS classes, allowing one class to inherit styles from another.
- Functions: Provides a way to write reusable code that can be used to perform calculations or manipulate values in CSS.
GIF89a v. GIF87a
GIF89a is an updated version of the GIF87a format that supports transparent backgrounds, animation loops, and additional features.
float
The float property in CSS is used to position an element to the left or right of its container, allowing text and other elements to wrap around it.
Image interlacing
Image interlacing is a technique used to load images gradually, where a low-resolution version of the image is displayed first and then progressively more detailed versions are added until the full image is displayed.
Integrating HTML, CSS, and Media
video element
The video element is used to embed video content into a web page, allowing users to play, pause, and control the playback of video files directly in the browser without the need for a separate video player.
- attributes
- controls
- Adds standard controls
- loop
- continuously loops the video playback.
- poster
- Specifies image
- file formats
- MP4
- widely supported by most devices and platforms and is commonly used for sharing video content online
- WebM
- designed to be used for HTML5 video and is supported by popular web browsers such as Chrome and Firefox
- Ogg
- used primarily for high-quality streaming and is often used in combination with the Vorbis audio codec
The Box Model
The box model is essentially a rectangular box that encloses the content of an element, along with optional borders, padding, and margins.
- Content
- The actual content of the HTML element, such as text or images.
- Padding
- The space between the content and the border.
- Padding is used to create space around the content, making it easier to read and more visually appealing.
- Border
- A line or area that surrounds the padding and content, creating a boundary between the element and the rest of the page
- Margin
- The space outside the border, which separates the element from other elements on the page.
Positioning Schemes
- Static
- This is the default positioning scheme, in which an element is positioned according to the normal flow of the document.
- Relative
- In relative positioning, an element is positioned relative to its normal position in the document flow
- Absolute
- In absolute positioning, an element is positioned relative to the nearest positioned ancestor element (an element with a position property other than static).
- If no ancestor elements are positioned, the element is positioned relative to the document itself.
Markup and HTML5
HTML versions
- HTML 1.0 (1991) - The first version of HTML, which introduced basic markup tags for creating web pages.
- HTML 2.0 (1995) - An improved version of HTML 1.0 that introduced new features like tables, image maps, and form elements.
- HTML 3.2 (1997) - A major upgrade that standardized many of the features previously implemented differently by different browsers and added support for style sheets.
- HTML 4.01 (1999) - The last version of HTML before the introduction of XHTML, which added more features like frames and multimedia support.
- XHTML 1.0 (2000) - A stricter, more modular version of HTML that follows the rules of XML and requires all tags to be closed and all attributes to be quoted.
- HTML5 (2014) - The current version of HTML that introduces new tags and attributes for multimedia, graphics, and interactivity, as well as new APIs for web applications.
Web Forms
Purpose
The purpose of an HTML form is to collect and submit data from website visitors to a server, allowing users to input data through various form controls and interact with a website in a more personalized and effective manner.
Elements
<form>
element: This is the container element that defines the start and end of the form.- Form controls:
<input>
element: This is the most commonly used form control, and it allows users to enter text, numbers, dates, and other types of data.<textarea>
element: This form control allows users to enter multi-line text, such as comments or messages.<select>
element: This form control allows users to select options from a dropdown list.<button>
element: This element is used to create a clickable button that can trigger an action or submit the form.- Other form controls include checkboxes, radio buttons, and file upload controls which I will give examples for below.
<label>
element: This element is used to provide a label or description for each form control, which helps users understand what information they should enter.- Action attribute: This attribute specifies the URL of the server-side script that will process the form data.
- Method attribute: This attribute specifies the HTTP method used to submit the form data to the server, which is typically either GET or POST.
Form examples
<form action="/submit-form" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="5" required></textarea>
<label for="country">Country:</label>
<select id="country" name="country">
<option value="USA">United States</option>
<option value="CAN">Canada</option>
<option value="MEX">Mexico</option>
</select>
<label for="subscribe">Subscribe to newsletter:</label>
<input type="checkbox" id="subscribe" name="subscribe" value="yes">
<label for="gender">Gender:</label>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label>
<button type="submit">Submit</button>
</form>
Industry Standards
Server-Side Languages
- Server-side languages are executed on the server.
- Server-side languages are used to create dynamic web content.
- Server-side languages are typically more powerful than client-side languages.
- Common languages:
- PHP
- Ruby
- Python
- Java
- JavaScript (Node.js)
- Commonly used for:
- Dynamic web content generation
- User authentication and security
- Data processing and manipulation
DOM
The DOM stands for Document Object Model. It is a programming interface for HTML and XML documents, which represents the document as a tree-like structure of objects.
The DOM allows developers to:
- Manipulate content
- Handle events
- Change styles dynamically
By using the DOM, developers can create dynamic and interactive web pages using programming languages like JavaScript. This allows for rich user experiences without the need for server-side processing or page reloads.
// Get the div element by its ID
var myDiv = document.getElementById("myDiv");
// Create a DOM object for the div element
var myDivObject = new Object();
myDivObject.element = myDiv;
myDivObject.color = "blue";
myDivObject.showColor = function() {
alert(this.color);
};
In this example, we first use the
getElementById()
method to get
the <div>
element with
an ID of "myDiv". We then create a new
JavaScript object called
myDivObject
, which has three
properties:
element
- This property contains a reference to the DOM element that we retrieved earlier.color
- This property stores the color "blue".showColor()
- This is a method that displays the value of thecolor
property in an alert dialog box.
Now we can use the
myDivObject
object to
manipulate the <div>
element and its properties. For example, we
could change the color of the element like
this:
myDivObject.element.style.backgroundColor = "red";
This would change the background color
of the <div>
element to
red. We could also call the
showColor()
method to display
the color property in an alert dialog
box:
myDivObject.showColor();
This would display the message "blue" in an alert dialog box.
HTML5 API
An HTML5 API is a set of JavaScript functions and methods that are provided by modern web browsers as part of the HTML5 specification.
Editors and Mobile Sites
Optimizing a site for mobile devices:
- Use responsive web design to ensure the website adapts to different screen sizes
- Minimize page load times by optimizing images, reducing code and scripts, and using caching
- Optimize navigation for mobile by using dropdown menus, hamburger menus, or other mobile-specific options
- Make sure all interactive elements (buttons, links, forms, etc.) are easy to use on touchscreens
- Test the website across different mobile devices and web browsers to ensure compatibility and functionality
Viewport
The viewport meta tag is used in HTML to provide instructions to web browsers on how to display the content of a web page on different devices.
AJAX
AJAX (Asynchronous JavaScript and XML) is a web development technique that allows web pages to dynamically update content without requiring a full page reload.
ATAG
The W3C Authoring Tools Accessibility Guidelines (ATAG) 2.0 is a technical standard that explains how to make web content authoring tools more accessible and supportive of accessible web content12. It has two parts:
- Covers how to make the authorinag tools themselves accessible to people with disabilities
- Covers how to help authors create more accessible web content that conforms to Web Content Accessibility Guidelines (WCAG)1
Web Dev for Business
Project Cycle
- The web development project cycle includes creating and documenting an initial plan, obtaining input from stakeholders, considering technical and non-technical concerns, developing and publishing the website, and ongoing maintenance.
- The website plan should include a statement about the purpose and intended audience of the site, a rough outline of necessary pages, and an estimate of required technologies.
- Wireframing can be a helpful tool in the planning process, involving the development of an outline for a website's layout and navigation.
- Stakeholder and audience input is crucial in developing a website with a clear message and focus, and design considerations such as fonts, images, color, and language choice should be carefully considered to appeal to the intended audience.
- Regular validation of the site should occur throughout the development process, and stakeholder input can help determine necessary information for the site's success.
- The Waterfall Model is the earliest and most widely used SDLC (Software Development Life Cycle) approach.
- It is a linear-sequential model that divides the software development process into distinct phases.
- Each phase must be completed before the next phase can begin, with no overlapping of phases.
- The phases are: Requirement Gathering and analysis, System Design, Implementation, Integration and Testing, Deployment of system, and Maintenance.
- The Waterfall Model is suitable for projects with well-documented and stable requirements, clear product definition, and ample resources.
- Advantages include simplicity, easy management, and well-documented process and results.
- Disadvantages include high risk and uncertainty, poor suitability for complex or ongoing projects, and difficulty accommodating changing requirements.
Accessibility
- The Americans with Disabilities Act (ADA) was enacted in 1990 to protect the civil rights of disabled people and ensure equal employment opportunities, public accommodations, and electronic information accessibility.
- The ADA applies to cyberspace communications, and web designers should create "reasonable accommodation" in their websites for people with disabilities.
- Section 508 of the Rehabilitation Act requires that Federal agencies provide accommodations for users with disabilities for all electronic and information technology developed, procured, maintained or used by federal agencies.
- Section 508 includes specific standards for websites, such as providing text-based equivalents for all non-text elements, making multimedia content accessible to disabled persons, and identifying all row and column headers for tables.
- The World Wide Web Consortium (W3C) is an international organization that creates all web standards, while the Web Accessibility Initiative (WAI) aims to ensure that core technologies used on the web are equally accessible to all users.
Ecommerce
Business models
- B2C (Business-to-consumer): Sells directly to end-users with a shorter sales cycle and lower average order value than B2B.
- B2B (Business-to-business): Sells to another business with a longer sales cycle, higher order value, and more recurring purchases.
- B2B2C (Business-to-business-to-consumer): Sells in partnership with another organization to an end customer.
- B2G (Business-to-government): Sells and markets to government entities or public administrations.
- C2B (Consumer-to-business): Allows individuals to sell goods and services to companies.
- D2C (Direct-to-consumer): Sells its own product directly to end customers, without third-party wholesalers or retailers.
- C2C (Consumer-to-consumer): Connects consumers to exchange goods and services and charges transaction or listing fees.
Value Delivery Methods
- White labeling: Product produced by one company and sold under another company's brand name.
- Private labeling: Similar to white labeling, but the retailer creates their own brand name for the product.
- Wholesaling: Manufacturer sells products in bulk to retailers or distributors at a discounted price.
- Dropshipping: Retailer orders products from a manufacturer or wholesaler only after receiving an order from a customer.