0% found this document useful (0 votes)
7 views39 pages

HTML Pstudy Notes

The document provides an extensive overview of HTML and CSS, detailing definitions, purposes, usage, tips, and connections for various elements and attributes. It covers foundational concepts such as the structure of HTML documents, the role of CSS in styling, and specific tags like <a>, <img>, <audio>, and <video>. Additionally, it includes best practices for coding and organizing web content effectively.

Uploaded by

deez.memes.476
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views39 pages

HTML Pstudy Notes

The document provides an extensive overview of HTML and CSS, detailing definitions, purposes, usage, tips, and connections for various elements and attributes. It covers foundational concepts such as the structure of HTML documents, the role of CSS in styling, and specific tags like <a>, <img>, <audio>, and <video>. Additionally, it includes best practices for coding and organizing web content effectively.

Uploaded by

deez.memes.476
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Excellent! Let’s apply the Note Expansion Method to your notes.

I’m keeping your exact order and expanding each point


into a short but in-depth set of notes. This will help you both understand and practically use each concept.

Here’s your expanded notes:

HTML NOTES:

✅ Expanded Notes (Using Note Expansion Method)

HTML

 Meaning / Definition
HyperText Markup Language — the core language for creating web pages.

 Uses / Purpose
Structures content into elements like headings, paragraphs, lists, forms, etc.

 How to Use
Write tags surrounded by < >, e.g. <p>Hello</p>.

 Tips

o Keep code readable with indentation.

o Validate HTML for errors.

 Connections
Works with CSS (styling) and JavaScript (interactivity).

CSS

 Meaning / Definition
Cascading Style Sheets — language for styling HTML documents.

 Uses / Purpose
Controls layout, colors, fonts, spacing, and overall design.

 How to Use

o Inline: <p style="color:red;">

o Internal: inside <style> tags in HTML.

o External: in separate .css files linked via <link>.

 Tips

o Use external stylesheets for maintainability.

o Follow CSS best practices (avoid inline styles for large projects).
 Connections
Works with HTML and affects how elements appear visually.

Most servers see the index file as the homepage


 Meaning / Definition
[Link] or [Link] is often the default file loaded when visiting a domain.

 Uses / Purpose
Provides the main landing page of a website.

 How to Use
Name your home page [Link] or configure the server to recognize a different file.

 Tips
Keep index pages clean and lightweight for faster loading.

 Connections
Relevant when deploying websites to servers.

Head contains info about the body

 Meaning / Definition
The <head> element stores metadata about the HTML document.

 Uses / Purpose
Includes:

o <title>

o <meta>

o CSS/JS links

o SEO info

 How to Use
Place inside <html> and before <body>.

 Tips

o Keep head organized.

o Always set a page title and charset.

 Connections
Connects to CSS, JavaScript, SEO.

Body contains visible content in the page

 Meaning / Definition
The <body> element holds all visible page content.
 Uses / Purpose
Displays text, images, links, videos, etc.

 How to Use
Everything visible goes between <body> and </body>.

 Tips
Organize content with semantic tags like <main>, <header>, <footer>.

 Connections
Linked to CSS and JavaScript for style and behavior.

Self-Closing Tag

 Meaning / Definition
Tags that do not wrap content and close themselves (e.g. <br />).

 Uses / Purpose
Insert standalone elements like line breaks or horizontal rules.

 How to Use
<tag /> or simply <tag> (HTML5 allows omission of the slash).

 Tips
Always check whether a tag requires a closing pair.

 Connections
Often used in page layout.

<br>

 Meaning / Definition
Line break.

 Uses / Purpose
Forces text to move to a new line.

 How to Use
<br>

 Tips

o Avoid overusing <br> for layout.

o Use CSS margins or block elements instead.

 Connections
Used in text formatting.

<hr>

 Meaning / Definition
Horizontal rule, creates a visible line.
 Uses / Purpose
Separates content visually.

 How to Use
<hr>

 Tips

o Style with CSS for thickness, color, etc.

 Connections
Used in layouts and section breaks.

<pre>

 Meaning / Definition
Preformatted text block.

 Uses / Purpose
Preserves spaces, tabs, and line breaks as typed.

 How to Use

 <pre>

 Text

 exactly

 as typed

 </pre>

 Tips
Useful for displaying code snippets.

 Connections
Related to code formatting.

Hyperlink

 Meaning / Definition
Clickable text, image, or element that leads to another page or resource.

 Uses / Purpose
Navigate between:

o Web pages

o Sections on a page

o External sites

o Downloads
 How to Use
<a href="URL">Link Text</a>

 Tips

o Use descriptive link text.

o Consider target="_blank" for external links.

 Connections
Tied to URLs, attributes like href and target.

<a> tag (Anchor)

 Meaning / Definition
HTML tag for creating hyperlinks.

 Uses / Purpose
Wraps text or elements to make them clickable.

 How to Use

 <a href="[Link] Example</a>

 Tips

o Add title for extra info.

o Use IDs to link within the same page: <a href="#section2">

 Connections
Related to hyperlinks, URLs.

Attribute Tags

 Meaning / Definition
Extra details added to HTML elements as name-value pairs.

 Uses / Purpose
Change behavior, appearance, or functionality.

 How to Use
<tag attribute="value">

 Tips

o Use quotes around attribute values.

o Remember attributes are case-insensitive in HTML.

 Connections
Core to writing meaningful HTML.

href
 Meaning / Definition
Hypertext reference — the URL where a link points.

 Uses / Purpose
Directs the browser to a specific location.

 How to Use
<a href="[Link]

 Tips

o Use relative paths for internal links.

o Use absolute paths for external sites.

 Connections
Used with <a>, <link>, <base>.

target

 Meaning / Definition
Specifies where to open the linked document.

 Uses / Purpose
Controls browser tab/window behavior.

 How to Use

 <a href="[Link] target="_blank">Open New Tab</a>

 Tips

o _blank opens a new tab.

o _self is the default.

 Connections
Related to hyperlinks.

Absolute URL

 Meaning / Definition
A full web address including protocol and domain.

 Uses / Purpose
Links to external resources.

 How to Use
[Link]

 Tips
Necessary when linking outside your website.

 Connections
Contrasts with relative URLs.
Relative URL

 Meaning / Definition
A URL relative to the current page’s location.

 Uses / Purpose
Internal linking within the same website.

 How to Use

o [Link]

o ../images/[Link]

 Tips
Use relative URLs to keep your site portable.

 Connections
Contrasts with absolute URLs.

<img>

 Meaning / Definition
Displays images on web pages.

 Uses / Purpose
Adds graphics, logos, icons.

 How to Use

 <img src="[Link]" alt="Description">

 Tips

o Always include alt for accessibility.

o Optimize images for web.

 Connections
Related to links, folders, multimedia.

src

 Meaning / Definition
Specifies the source file for an element.

 Uses / Purpose
Used in:

o <img>

o <audio>

o <video>
o <script>

 How to Use
<img src="[Link]">

 Tips
Paths can be absolute or relative.

 Connections
Works with media and external resources.

alt

 Meaning / Definition
Alternate text for an image.

 Uses / Purpose

o Accessibility for screen readers.

o Displays when image can’t load.

 How to Use
<img src="[Link]" alt="A cute cat">

 Tips
Keep alt text descriptive but concise.

 Connections
Related to accessibility.

height/width (Images)

 Meaning / Definition
Controls size of images.

 Uses / Purpose
Define display dimensions in pixels or percentages.

 How to Use
<img src="[Link]" width="200" height="150">

 Tips
Use CSS for responsive sizing.

 Connections
Works with layout design.

Turning <img> into a hyperlink

 Meaning / Definition
Wrap an image in an <a> tag.
 Uses / Purpose
Clickable images.

 How to Use

 <a href="[Link]

 <img src="[Link]" alt="Logo">

 </a>

 Tips
Add alt text for accessibility.

 Connections
Combines images and links.

Adding GIF

 Meaning / Definition
Use animated GIFs like regular images.

 Uses / Purpose
Add animations.

 How to Use
<img src="[Link]" alt="Funny animation">

 Tips
Optimize GIFs to avoid large file sizes.

 Connections
Part of multimedia.

Putting images into separate folders

 Meaning / Definition
Organize images in folders.

 Uses / Purpose
Keeps project clean and maintainable.

 How to Use

 <img src="images/[Link]">

 Tips
Maintain consistent folder structure.

 Connections
Works with relative paths.

Correct navigation/location of the image in href


 Meaning / Definition
Use correct path to files in attributes.

 Uses / Purpose
Ensures links and images load correctly.

 How to Use
Relative or absolute paths depending on folder structure.

 Tips
Double-check paths after moving files.

 Connections
Core concept in HTML development.

<audio>

 Meaning / Definition
Embeds audio files on a webpage.

 Uses / Purpose
Play music, podcasts, sound effects.

 How to Use

 <audio controls>

 <source src="song.mp3" type="audio/mpeg">

 </audio>

 Tips

o Provide multiple formats for browser support.

o Use fallbacks for unsupported browsers.

 Connections
Related to multimedia.

Audio attributes

 controls → shows playback buttons.

 autoplay → plays audio automatically.

 muted → starts muted.

 loop → repeats audio.

 fallbacks → text or links shown if audio unsupported.

Audio codes → <source>


 Meaning / Definition
Defines audio file and format.

 Uses / Purpose
Improves cross-browser support.

 How to Use

 <source src="[Link]" type="audio/ogg">

 Tips
Add multiple sources for compatibility.

 Connections
Used in audio and video tags.

<video>

 Meaning / Definition
Embeds video content on a webpage.

 Uses / Purpose
To display video files like .mp4, .webm, or .ogg.

 How to Use

 <video controls>

 <source src="movie.mp4" type="video/mp4">

 </video>

 Tips

o Always include controls for user interaction.

o Add multiple source formats for browser compatibility.

 Connections
Related to multimedia, like <audio> and <source>.

Video Attributes

 controls → shows video controls like play, pause, volume.

 autoplay → plays video automatically.

 muted → starts video muted.

 loop → plays video continuously.

 poster (optional) → shows an image before video plays.

Video Codes
 Source Code

o <source src="video.mp4" type="video/mp4">

o Used inside <video> for flexibility.

o Backup formats (e.g., .webm, .ogg) help ensure browser support.

 Direct Source in <video>

o <video src="video.mp4" controls></video>

o Simpler, but doesn't support multiple formats.

 Tip: Use <source> for better fallback handling.

Icon

 Meaning / Definition
Small graphical symbol representing an action, brand, or file.

 Uses / Purpose
Used in UI/UX design, favicons, buttons.

 How to Use
With <link rel="icon" href="[Link]"> in the <head>.

 Tips

o Use .ico, .png, or .svg formats.

o Ideal sizes: 16×16, 32×32.

 Connections
Uses the <link> tag.

<link> Tag

 Meaning / Definition
Connects external resources (like stylesheets or icons) to HTML.

 Uses / Purpose
Loads CSS files, icons, fonts.

 How to Use

 <link rel="stylesheet" href="[Link]">

 Tips
Place inside <head> for CSS loading priority.

 Connections
Works with attributes: rel, href, type.

Text Formats (10 types)


1. Bolded → <b> or <strong> (use <strong> for importance).

2. Italic → <i> or <em> (use <em> for emphasis).

3. Underlined → <u>

4. Deleted → <del>

5. Big → <big> (deprecated; use CSS instead)

6. Small → <small>

7. Subscript → <sub>

8. Superscript → <sup>

9. Monospaced → <code> or <tt> (deprecated)

10. Marked → <mark> (highlights text)

 Tips: Use semantic tags like <strong> or <em> for accessibility and SEO.

Grouping Elements for Styling

span Container

 Meaning / Definition
Inline container for text.

 Uses / Purpose
Apply styles to part of text without breaking layout.

 How to Use

 <span style="color:red;">Red Text</span>

 Tips
Use for small style tweaks.

div Container

 Meaning / Definition
Block-level container for grouping elements.

 Uses / Purpose
Group and apply styles/layouts to multiple elements.

 How to Use

 <div class="section">

 <p>Paragraph 1</p>

 <p>Paragraph 2</p>

 </div>
 Tips
Use semantic tags like <section>, <article> when possible for meaning.

Listing

Unordered List (<ul>)

 Bullet points.

 Use <li> for list items.

 Nest lists with another <ul> inside <li>.

Ordered List (<ol>)

 Numbered items.

 Works like <ul> with <li>.

 Nestable.

Description List (<dl>)

 Key-value style lists.

 Terms: <dt>

 Descriptions: <dd>

 Example:

 <dl>

 <dt>HTML</dt>

 <dd>Markup language for web pages.</dd>

 </dl>

 Tips
Use CSS for spacing, not <br>.

Styling Code (Multiple Styles)

 How to Use
Use semicolons to separate properties:

 <p style="color:blue; font-size:20px; background:lightgray;">Styled Text</p>

 Tips
Use external CSS for cleaner, reusable code.
Tables

Tags

 <table>: table container

 <thead>: header section

 <tbody>: body section

 <tr>: table row

 <th>: header cell

 <td>: data cell

Attributes (HTML-based)

 border, align, width — mostly deprecated, use CSS.

Tips

 Use modern CSS for styling tables.

 Avoid deprecated tags (shown in red in editors like VSCode).

Buttons

<button> Tag

 For interactive buttons.

Linking via <a href>

 Make button behave like a link:

 <a href="[Link]"><button>Go</button></a>

Styling

 Use CSS:

 border-radius: 10px;

 font-size: 20px;

JavaScript Button Example

<button onclick="doThings()" style="...">Java Button</button>

<p id="hello">Hello</p>

<script>

function doThings(){

[Link]("hello").innerHTML = "Goodbye"

}
</script>

 Meaning: On button click, change the paragraph content.

 Tips: Use id for targeting. Use functions for reusable behavior.

Form

<form> Tag

 Meaning / Definition
Container that groups user input fields for submission.

 Uses / Purpose
Collects data like names, emails, comments, etc.

 How to Use

 <form action="[Link]" method="post">

 <!-- input fields go here -->

 </form>

 Tips

o Always define action and method.

o Use id and for attributes for better accessibility.

 Connections
Related to backend processing (e.g. PHP).

action

 Meaning / Definition
URL where the form data will be sent upon submission.

 Uses / Purpose
Connects front-end form to a server-side script (like PHP).

 How to Use
action="[Link]"

 Tips

o Can be relative or absolute URL.

o For testing, leave blank or use #.

 Connections
Works with backend languages (e.g. PHP).

method
 Meaning / Definition
Defines how form data is sent to the server.

 Values:

o get:

 Appends data to URL (e.g. ?name=Bob)

 Used for non-sensitive data.

o post:

 Sends data in the HTTP body.

 Better for sensitive data.

 Tips
Prefer post for logins, passwords, etc.

enctype

 Meaning / Definition
Specifies how form data should be encoded.

 Values:

o application/x-www-form-urlencoded (default)

o multipart/form-data → required for file uploads

o text/plain (rarely used)

 How to Use

 <form enctype="multipart/form-data">

 Connections
Essential for uploading images or files.

<label>

 Meaning / Definition
Text label describing a form element.

 Uses / Purpose
Improves usability and accessibility.

 How to Use

 <label for="username">Username:</label>

 <input type="text" id="username">

 Tips
Clicking the label focuses the input.
 Connections
Works with id attributes.

<input>

 Meaning / Definition
Generic tag for capturing user data.

 Uses / Purpose
Text fields, checkboxes, radio buttons, file uploads, etc.

 Tips
Always add descriptive labels for accessibility.

 Connections
Often paired with <label>.

Common Input Types

Text Input

<input type="text" id="Username" required minlength="6" maxlength="15" placeholder="Spongebob">

 Purpose: Single-line text input.

 Attributes:

o required

o minlength

o maxlength

o placeholder

Password Input

<input type="password" id="Password" required placeholder="*******">

 Hides characters.

Email Input

<input type="email" id="email" required placeholder="Squarepants@[Link]">

 Checks for proper email format.

Telephone Input

<input type="tel" id="phonenumber" placeholder="123-456-7890" required pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}">

 Validates phone number formats.


Date Input

<input type="date" id="bday">

 Provides a date picker.

Number Input

<input type="number" id="amount" min="0" max="99" value="1">

 Only numeric input allowed.

Radio Buttons

<input type="radio" id="Mr." name="title" value="Mr.">

 Single selection from a group.

Select Dropdown

<select id="payment">

<option value="visa">Visa</option>

</select>

 Dropdown list of options.

Checkbox

<input type="checkbox" id="subscribe">

 Toggles on/off.

Textarea

<textarea id="comment" rows="3" cols="25" placeholder="Comment Here!"></textarea>

 Multi-line input.

File Upload

<input type="file" id="file" accept="image/png, image/jpeg">

 Uploads files from the user’s computer.

Reset Button
<input type="reset">

 Clears the form fields.

Submit Button

<input type="submit">

 Sends data to the server.

<header>

 Meaning / Definition
Container for introductory or navigational content.

 Uses / Purpose
Often includes:

o Logo

o Site name

o Navigation bar

 How to Use

 <header>

 <h1>My Website</h1>

 <nav> ... </nav>

 </header>

 Connections
Part of semantic HTML.

<footer>

 Meaning / Definition
Container for closing or secondary content.

 Uses / Purpose
Often includes:

o Copyright info

o Links

o Contact details

 How to Use

 <footer>

 <p>&copy; 2025 My Website</p>


 </footer>

 Tips
Use <small> for copyright text.

<main>

 Meaning / Definition
Represents the central content of a page.

 Uses / Purpose
Focus area for unique content.

 How to Use

 <main>

 <h2>Welcome</h2>

 <p>Page content goes here.</p>

 </main>

 Connections
Good for SEO and accessibility.

⚠️What Could Be Improved

Avoid <br> for layout

 <br> is valid for single line breaks.

 Not ideal for layout or spacing.

Instead use block elements like <p>, <div>, or CSS margins/padding.

✅ Example:

Bad:

Author: Kervs<br>

&copy; Copyright Reserved<br>

Better:

<footer>

<p>Author: Kervs</p>

<p>&copy; Copyright Reserved</p>

</footer>

Or using a list:

<footer>
<ul>

<li>Author: Kervs</li>

<li>&copy; Copyright Reserved</li>

</ul>

</footer>

Move Styles to CSS

Instead of:

<footer style="background-color: bisque;">

✅ Use a class:

<footer class="site-footer">

And CSS:

.site-footer {

background-color: bisque;

padding: 10px;

text-align: center;

Use <small> for legal text

e.g. Copyright:

<small>&copy; 2025 My Website</small>

CSS NOTES:

Here’s your expanded version using the Note Expansion Method for your CSS & HTML notes:

CSS (Cascading Style Sheets)

 Meaning / Definition
A language used to style and visually format HTML elements on a webpage.

 Uses / Purpose

o Applies colors, layouts, fonts, borders, spacing, and positioning.


o Separates content (HTML) from presentation (CSS).

 How to Use / Basic Types

o Inline CSS: Inside an HTML tag using the style attribute.


e.g <p style="color:red;">Text</p>

o Internal CSS: Inside a <style> tag placed within the <head> of an HTML document.

o External CSS: In a separate .css file linked via <link rel="stylesheet" href="[Link]">.

 Tips / Best Practices

o Use external CSS for larger projects (better maintainability).

o Avoid inline styles except for quick testing or exceptions.

o Be mindful of selector specificity (ID > Class > Tag).

 Connections

o Works closely with HTML structure.

o Uses selectors like ID (#id) and Class (.class) to target elements.

CSS Selectors: ID vs Class

 ID (#idName)

o Used to style a single, unique element.

o Assigned via id="name" in HTML.

o In CSS: #name { color: black; }

o Higher specificity than class.

 Class (.className)

o Used to group and style multiple elements.

o Assigned via class="name" in HTML.

o In CSS: .name { color: black; }

 Tips / Best Practices

o Don’t reuse IDs; for multiple elements use classes.

o If ID and class both apply a style (e.g., color), the ID takes priority.

o The cascading behavior of CSS means child elements may inherit styles from parent (e.g., styles on
<body>).

CSS Colors

 Values You Can Use


o Named Colors: e.g., red, blue, coral

o Hexadecimal: #ff0000

o RGB: rgb(255,0,0)

o HSL: hsl(0, 100%, 50%)

o Color Picker: Some editors offer GUI color pickers for visual selection.

 Uses

o In any color-related CSS property: color, background-color, border-color, etc.

CSS Fonts

 font-family: ;

o Specifies the typeface used.

o Always list fallback fonts:


font-family: 'Arial', sans-serif;

 Font Sizes

o em: Relative to the parent (1em = 100%)

o px: Pixels (fixed size, default ~16px)

 How to Add Custom Fonts

o Google Fonts:
Copy the embed link into <head> and use its font name in CSS.

o Download & Install TTF

 Place .ttf in a folder (e.g., font/)

 Use @font-face:

@font-face {

src: url(font/[Link]);

font-family: yourCustomName;

 Tips

o Always have a fallback font.

o Don’t overuse many fonts on one page.

CSS Borders

 Individual Properties
o border-style: solid;

o border-width: 3px;

o border-color: blueviolet;

o border-radius: 5px; (rounds corners)

 Shorthand

o border: 3px solid black;

 Border Radius Limit

o Rounded corners have a max value beyond which they don't become more rounded.

 Directional Borders

o border-top, border-right, etc. to apply styles only to specific sides.

 Types of Borders

o dashed, dotted, double, groove, ridge, inset, outset, none, hidden

CSS Shadows

 Text Shadow

text-shadow: 2px 2px 5px red;

 Syntax: H-offset V-offset Blur Color

 Multiple shadows: Separate by commas.

 Box Shadow

box-shadow: 2px 2px 5px red;

 Applies to non-text elements like <div>, <button>, etc.

 Same syntax as text-shadow.

 Tips

o Use subtly for depth.

o Overuse can harm readability.

CSS Margins

 Definition

o Space outside the border of an element.

 Uses

o Controls spacing between elements.

 Shorthand
o margin: 10px; (all sides)

o margin: 10px 20px; (top-bottom, left-right)

 Directional

o margin-top, margin-left, etc.

 Special Cases

o margin-left: auto; → pushes element to the right.

o margin: auto; → centers the element (if width is defined).

 Tools

o Use browser inspect tool to see margin/padding visual guides.

CSS Floats

 Definition

o Allows elements (like images) to float to the left or right, allowing inline content to wrap around them.

 How to Use

o float: left; or float: right;

 Common Usage

o Useful for text wrapping around images.

 Problem

o Parent elements sometimes collapse if they only contain floated elements.

 Fix

display: flow-root;

 Creates a new block formatting context to contain floats properly.

CSS Overflow

 Definition: Controls what happens when content overflows the bounds of its container.

 Use: To manage how overflowing content is displayed (hidden, scrollable, etc.).

 States:

o **visible**: Default; overflow content is shown outside the box.

o **hidden**: Cuts off content that exceeds container bounds. Content is still selectable.

o **clip**: Like hidden, but used with overflow-clip-margin to control how much is clipped.

o **scroll**: Adds scrollbars always, even if no overflow is present.

o **auto**: Scrollbars only appear when overflow exists.


 Tip: Use clip if you need precise overflow clipping with margin control.

 Connected To: box-sizing, layout sizing, scroll behavior.

CSS Display

 Definition: Specifies how an element is displayed in the layout (block, inline, etc.).

 Use: To change the layout behavior of HTML elements.

 Types:

o **block-level**: Starts on a new line; takes full width. e.g., <div>, <p>, <h1>.

 Can modify width and height.

o **inline**: Stays on the same line; only takes up necessary width. e.g., <span>, <a>, <img>.

 Cannot set width or height.

 Common Values:

o block, inline, inline-block, none

 Tip: Use inline-block to combine layout flexibility of block and inline.

 Also Related: visibility (e.g., visibility: hidden; hides but retains space).

CSS Height and Width

 Definition: Specifies the size of elements.

 Properties:
height, width, min-height, max-height, min-width, max-width, text-align

 Tip:

o % is relative to the parent or viewport.

o Use box-sizing: border-box; to include padding & border in size.

o Universal selector * { box-sizing: border-box; } makes layout predictable.

 Connected To: Padding, margin, overflow, responsive design.

CSS Position

 Definition: Controls the positioning method used for an element.

 Values:

o **static**: Default; normal document flow.

o **relative**: Moves from its normal position using top, left, etc.

o **absolute**: Positioned relative to nearest positioned ancestor (not static).


o **fixed**: Positioned relative to the viewport; stays in place on scroll.

o **sticky**: Switches between relative and fixed depending on scroll.

 Tip: Use relative for small nudges, absolute for floating inside containers, fixed for headers/menus.

 Connected To: Layout containers, scroll behavior, z-index.

CSS Background-Image

 Definition: Applies an image to the background of an element.

 Key Properties:

o background-image: url('...');

o background-repeat: no-repeat;

o background-position: center;

o background-attachment: fixed;

o background-size: cover;

 Tip: Use cover for full-element fit and fixed for parallax-style effects.

 Connected To: Layout design, media queries, section backgrounds.

CSS Combinators

 Definition: Defines relationships between selectors.

 Types:

o descendant (space): targets all matching children inside parent.

o child (>): targets direct children only.

o general sibling (~): targets all siblings after an element.

o adjacent sibling (+): targets the immediate next sibling.

 Syntax: selector > selector { ... }

 Tip: Use combinators to style elements in structured layouts or nested HTML.

 Connected To: Hierarchical design, specificity, pseudo-classes.

CSS Pseudo-Classes

 Definition: Adds special behavior/states to selectors.

 Common Pseudo-Classes:

o :link — Unvisited link

o :hover — When mouse hovers


o :active — When clicked

o :visited — Already visited links

 Negation: :not() — Selects anything that does not match.

o Example: selector:not(:hover)

 nth-child() Variants:

o nth-child(1) — First child

o nth-child(even) / odd

o nth-child(3n) — Every 3rd

o nth-child(3n+4) — Every 3rd + 4th

 With Combinators Example:

 #greeting p {

 display: none;

 }

 #greeting:hover p {

 display: block;

 }

 Connected To: Interactivity, transitions, animations, dynamic behavior.

CSS Pseudo-Elements

 Definition: Styles parts of elements without needing extra HTML.

 Syntax: selector::pseudo-element { ... }

 Common Pseudo-Elements:

o ::first-letter — Styles the first letter (e.g., headers).

o ::first-line — Styles only the first line of text.

o ::selection — Styles text being selected.

o ::before — Adds content before the element.

o ::after — Adds content after the element.

o ::marker — Styles list markers.

 Examples:

 h1::first-letter {

 font-size: 2em;

 }

 #fruit li::before {

 content: "🫠";

 }

 #Banana::after {

 content: "🍌🍌";

 }

 Tip: Great for icons, decorative elements, or content embellishment without extra tags.

 Connected To: Visual styling, accessibility, UX, animations.

CSS Pagination

 Meaning:

o A technique used to divide long content (like articles or search results) into multiple pages, making it
easier to navigate.

o Often used in blogs, forums, e-commerce product listings, etc.

 Key Components in the Sample:

 .pagination {

 text-align: center;

 }

 .pagination a {

 color: black;

 text-decoration: none;

 padding: 8px 15px;

 display: inline-block;

 }

 .pagination [Link] {

 background-color: rgb(14, 221, 97);

 font-weight: bold;

 border-radius: 5px;

 }

 .pagination a:hover:not(.active) {
 background-color: beige;

 border-radius: 5px;

 }

 How It Works:

o .pagination: Container for the pagination links.

o a: The page links styled to look like buttons.

o .active: Highlights the current page.

o :hover:not(.active): Adds hover effect but excludes the active link.

 Tips:

o Use consistent spacing (padding) for clickable areas.

o Highlight the active page to improve user experience.

o Keep contrast in mind for accessibility.

 Connected Topics:

o Pseudo-classes: :hover, :not() — allows targeting based on states.

o Box Model: Padding affects clickable area.

o Text alignment: Use text-align for layout control.

CSS Dropdown Menus

 Meaning:

o A UI component that shows a list of links or options when a button or element is hovered or clicked.

 Key Components in the Sample:

 .dropdown {

 display: inline-block;

 }

 .dropdown button {

 background-color: rgb(24, 189, 134);

 color: aliceblue;

 padding: 10px 15px;

 border: none;

 cursor: pointer;

 }

 .dropdown .content {
 display: none;

 position: absolute;

 background-color: rgb(22, 215, 151);

 min-width: 100px;

 box-shadow: 2px 2px 5px rgb(1, 67, 45);

 }

 .dropdown:hover .content {

 display: block;

 }

 .dropdown a {

 display: block;

 color: black;

 text-decoration: none;

 padding: 10px 15px;

 }

 .dropdown a:hover {

 background-color: aquamarine;

 }

 .dropdown:hover button {

 background-color: aqua;

 }

 How It Works:

o .dropdown: Contains the button and content.

o .content: Hidden by default, shown when .dropdown is hovered.

o position: absolute: Allows dropdown to appear over other elements.

o box-shadow: Adds depth.

 Tips:

o Keep the button accessible — consider tabindex or ARIA roles.

o Avoid relying only on :hover for mobile — consider JavaScript for touch interaction.

o Use min-width to ensure enough space for content.

 Connected Topics:

o Positioning: absolute, relative to nearest positioned ancestor.


o Pseudo-classes: :hover for interaction.

o Box Model: Padding and spacing.

 Personal Note:

o Since you're struggling with pseudo-classes/elements:

 :hover, :active, :focus = pseudo-classes (triggered by state)

 ::before, ::after = pseudo-elements (inject content)

CSS Navigation Bar

 Meaning:

o A structured block of links that let users move through different parts of a website.

o Uses <nav> to define semantic navigation areas.

 HTML Sample Breakdown:

o <nav class="navbar"> contains an unordered list <ul> with navigation links <li><a></a></li>.

 CSS Sample Breakdown:

 .navbar ul {

 list-style-type: none;

 background-color: bisque;

 padding: 0;

 margin: 0;

 overflow: hidden;

 }

 .navbar li {

 float: left;

 }

 .navbar a {

 display: block;

 color: brown;

 text-decoration: none;

 padding: 15px;

 text-align: center;

 }

 .navbar a:hover {
 background-color: burlywood;

 }

 How It Works:

o ul styles the list to remove bullets and set background.

o li { float: left; } places items horizontally.

o a is styled as a block element for full clickable area.

 Tips:

o Use overflow: hidden to contain floated elements.

o Be sure to clear floats (clearfix or flexbox) for larger layouts.

o Consider using Flexbox or Grid for modern layout control.

 Connected Topics:

o Semantic HTML: <nav>, <ul>, <li>, <a>

o Hover Effects: For feedback.

o Positioning: Float-based layout (older method).

CSS Website Layout

 Meaning:

o Structuring a full web page using semantic HTML and styled using CSS for layout and responsiveness.

 Semantic Tags:

o <header>, <nav>, <main>, <section>, <aside>, <article>, <footer> — each has a specific purpose for
content structure and accessibility.

 CSS Sample Breakdown:

 *{

 box-sizing: border-box;

 }

 aside, section, article {

 float: left;

 padding: 15px;

 }

 aside { width: 20%; }

 section { width: 40%; }

 article { width: 40%; }


 @media screen and (max-width:600px) {

 aside, section, article {

 width: 100%;

 }

 }

 How It Works:

o float: left lays out sections side-by-side on wider screens.

o Media query makes layout responsive — stacking sections on small screens.

o box-sizing: border-box simplifies layout by including padding/border in the total width.

 Tips:

o Use media queries to adapt to different screen sizes.

o Prefer Flexbox or Grid over float for newer layouts.

o Always reset box-sizing to border-box for predictable sizing.

 Connected Topics:

o Responsive Design: Using @media.

o Semantic HTML: Helps with SEO, accessibility, and maintainability.

o Box Model, Float, and Clearfix.

o CSS Reset: Normalize inconsistent browser defaults.

CSS Icon

 Font Awesome Integration

o A widely-used icon library that offers scalable vector icons (SVG) and social brand icons.

o Used by linking a CDN (<script src="[Link] inside <head>.

o Requires internet connection unless self-hosted.

 Icon Usage in HTML

o Icons are added using <i> or <span> tags with specific Font Awesome classes.

o Example:

o <i class="fa-brands fa-github fa-5x"></i>

 fa-brands: icon style (brands)

 fa-github: specific icon

 fa-5x: size (5x the base size)


 CSS Styling

o Container class like .icons is used to group or style multiple icons.

o Icons inside anchor tags (<a>) are clickable links—using target="_blank" opens them in a new tab.

 Tips & Connections

o Combine with hover effects, animations, or Flexbox for better layout control.

o Good for social media sections, navbars, buttons, etc.

CSS Flexbox

 display: flex

o Enables a flex container; children become flex items.

o Used for 1D layouts (either horizontal or vertical).

 flex-direction

o Sets main axis direction: row (default), column, row-reverse, column-reverse.

o Affects how items are laid out.

 justify-content

o Aligns items along the main axis.

o Values: flex-start, center, space-between, space-around, space-evenly, flex-end.

 align-items

o Aligns items along the cross axis (perpendicular).

o Values: stretch (default), center, flex-start, flex-end, baseline.

 flex-wrap

o Allows items to wrap into multiple lines: nowrap (default), wrap, wrap-reverse.

 align-content

o Aligns rows of flex items when there is wrapping.

o Only works if flex-wrap is used.

 column-gap / row-gap

o Adds spacing between columns or rows.

o Shorthand: gap: row column;

 align-self

o Overrides align-items for a single item.

 order

o Changes the order of appearance of flex items (default is 0).


o Lower values appear first.

CSS Transformations

 What it is:

o Allows you to visually manipulate elements in 2D or 3D space.

 Units:

o px, %, deg used in different transformations.

 Translate

o Moves the element:

 translate(x, y)

 translateX() / translateY()

 Rotate

o Rotates the element:

 rotateX(deg) / rotateY(deg) / rotateZ(deg)

 Scale

o Resizes the element:

 scale(x, y)

 scaleX() / scaleY()

 Skew

o Tilts the element:

 skew(x, y)

 skewX() / skewY()

 Multiple Transformations

o Can be combined in one line (order matters):

o transform: skewY(20deg) rotateZ(45deg) translateX(100px);

 Tips

o Use transitions or animations for smoother visual effects.

o Great for hover effects and dynamic UI.

CSS Animations

 @keyframes Rule

o Defines steps of animation.


o Use keywords from, to or percentages (0%, 100%, etc.)

o Example:

o @keyframes slide {

o from { transform: translateX(0); }

o to { transform: translateX(100px); }

o }

 Percentage Explanation

o Each % defines the element’s style at that point in time.

o CSS animates smoothly between defined steps.

 animation-iteration-count

o Number of loops: 1, 3, infinite

 animation-timing-function

o Controls the speed curve:

 Common: linear, ease-in, ease-out, ease-in-out, steps()

 Custom: cubic-bezier(x, y, x2, y2)

 To create your own cubic bezier:

 Open dev tools → select element → inspect animation-timing-function → edit graph.

 animation-direction

o Controls direction of animation:

 normal, reverse, alternate, alternate-reverse

 animation-play-state

o Starts/stops animation:

 running, paused

 Applying to Hover

o Example:

o #box:hover {

o animation-name: glow;

o animation-duration: 2s;

o animation-iteration-count: 1;

o animation-direction: alternate-reverse;

o animation-play-state: running;

o animation-timing-function: ease-in-out;
o }

CSS Sample Keyframes Used

 @keyframes kahitano

o Slides element right:

 from { transform: translateX(1000%); }

 @keyframes slideright

o Another sliding animation:

 to { transform: translateX(1000%); }

 @keyframes slideup / slidedown

o Moves vertically via translateY()

 @keyframes rotate

o Rotates 45 degrees at 20%

 @keyframes grow / shrink

o Uses scale(2,2) or scale(0.5, 0.5) to resize

 @keyframes fade

o Changes opacity to nearly invisible at 50%

 @keyframes colorChange

o Sequential background color changes at multiple steps

 @keyframes glow

o Adds glowing effect using box-shadow

 Connection Tip:

o Combine keyframes with hover states, transitions, and transform for interactive animations.

Let me know when you're ready to expand the next set.

You might also like