Javaqustions
Javaqustions
Webpage
- A Webpage is a single document on the web, typically written in HTML
(Hypertext Markup Language) and accessible through a unique URL.
- Webpages can contain text, images, videos, and other multimedia elements.
Static Webpage
- These are the webpages which are common for everyone or These are the
webpages which will display the same information for all users.
- Characteristics:
- Fixed Content: The content does not change unless manually updated by
the developer.
- No Interactivity: Static webpages typically do not involve any user
interaction beyond basic navigation.
- Simple to Create: Static webpages are usually created using only HTML
and CSS.
- Performance: They load quickly because they don't require server-side
processing.
Dynamic Webpage
- These web pages display different information for users.
Ex: Instagram, youtube, linkedIn
- Characteristics:
Network
- Characteristics:
- Examples: Gmail, Google Maps, Twitter, and many modern web apps.
- Characteristics:
- Traditional Structure: MPAs follow the traditional web structure
where each page is separate and involves a full -page reload.
- Server-Side Rendering: Most of the processing occurs on the server
side, where each request generates a new HTML page.
- DNS (Domain Name System): When a user enters a website’s URL, the DNS
translates the domain name into an IP address, which is used to locate the web
server where the website is hosted.
- Rendering: The server sends back the HTML, CSS, and JavaScript files to
the browser, which then renders the webpage for the user to view and interact
with.
1. Presentation Layer (Client Tier): This is the topmost layer where the
user interacts with the application. It typically includes the user interface
(UI) and the client-side logic (HTML, CSS, JavaScript).
2. Application Layer (Business Logic Tier): This middle layer processes
the business logic of the application. It handles the communication between the
presentation layer and the data layer, performing operations, calculations, and
decision-making.
3. Data Layer (Data Tier): The bottom layer is responsible for managing
data storage and retrieval. It interacts with databases or other storage systems
to store, query, and update data.
### Understanding the Full Form of HTML: Hypertext Markup Langu age
Hypertext
Markup
- Markup refers to the way tags are used to define the structure and
presentation of content in a document.
- The markup does not display directly on the webpage; instead, it instructs
the browser on how to render the content. For example, the `<p>` tag defines a
paragraph, and the `<h1>` tag defines the main heading.
- Example:
- <p> Hello world </p>
- <b> Hello world </b>
3. Types of HTML Tags
HTML tags are categorized into two types:
1. Paired Tags
- Definition: Paired tags require both an opening tag and a closing tag.
- Syntax: The closing tag is similar to the opening tag but includes a
forward slash (`/`).
- Example:
2. Unpaired Tags
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
1. <!DOCTYPE html>
2. <html>
- The `<html>` element is the root of an HTML document and contains all other
elements.
- Attributes: Typically includes the `lang` attribute to specify the language
of the document (e.g., `lang="en"` for English).
3. <head>
4. <body>
- The `<body>` section contains the content that is displayed on the webpage,
including text, images, links, and other elements.
<!-- ! Heading Tag -->
- The default font size for each heading tag is defined in terms of em
units.
- 1 em is equivalent to 16 pixels (px), which is the standard size of
normal text in web browsers.
- `<h1>`: 2 em (32px)
- `<h2>`: 1.5 em (24px)
- `<h3>`: 1.17 em (18.72px)
- `<h4>`: 1 em (16px)
- `<h5>`: 0.83 em (13.28px)
- `<h6>`: 0.67 em (10.72px)
- Example:
<h1>Front-End Development</h1>
- The `<p>` tag is a paired tag, meaning it has both an opening tag and
a closing tag.
-
<p>Content of the paragraph goes here.</p>
<!--! Formatting Tags -->
1. `<b>` Tag
- used for: Displays the content in bold format.
2. `<strong>` Tag
- used for: Displays the content in bold format, and conveys that the
information is important.
3. `<i>` Tag
- used for: Displays the content in italic format.
4. `<em>` Tag
- used for: Displays the content in italic format and adds emphasis, an
alternative to the `<i>` tag.
5. `<u>` Tag
- used for: Underlines the content.
6. `<ins>` Tag
- used for: Underlines the content, an alternative to the `<u>` tag, often
used to indicate inserted text.
7. `<strike>` Tag
- used for: Strikes off (crosses out) the content.
9. `<q>` Tag
- used for: Provides quotations around the content.
- Example: H<sup>2</sup>O
- Example: CO<sub>2</sub>
<p>
<pre>
this is pre tag
hello
hi
bye
</pre>
</p>
</body>
</html>
<!-- ! HTML Elements -->
- Basic Structure:
- Examples: <h1>,<div>,<p>
- Characteristics:
Syntax of Attributes
- Attributes are added within the opening tag of an element and follow this
format:
<element attribute="value">Content</element>
- `src` (Source):
- Specifies the path to the image file.
- This path can be a relative URL (based on the location of the HTML
file) or an absolute URL (complete path).
- `height`:
- Defines the height of the image in pixels or as a percentage of its
original size.
- `width`:
- Defines the width of the image in pixels or as a percentage of its
original size.
- Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Tag</title>
</head>
<body>
<h1>Image Tag</h1>
<p>here we will learn how to add image</p>
<img src="https://images.pexels.com/photos/994605/pexels-photo-
994605.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" alt="sea image"
height="200" width="200">
<img src="https://images.pexels.com/photos/189349/pexels-photo-
189349.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" alt="sun set"
height="200" width="300">
</body>
</html>
<!-- ! LIST IN HTML -->
1. Ordered List
- Purpose: Used to group related items in a sequential, numbered format. It
is often referred to as a Number List.
- Tags:
- <ol>: Denotes the start of an ordered list.
- <li>: Indicates each list item within the ordered list.
- Attributes:
- type: Specifies the type of numbering sequence.
- Values:
- 1 (default) - Numeric (1, 2, 3, ...)
- A - Uppercase letters (A, B, C, ...)
- a - Lowercase letters (a, b, c, ...)
- I - Uppercase Roman numerals (I, II, III, ...)
- i - Lowercase Roman numerals (i, ii, iii, ...)
- start: Specifies the starting number of the list.
- Values:
- 1 (default)
- Any other number to start the list from.
- reversed: Reverses the order of the list items.
2. Unordered List
- Purpose: Used to display a set of related items without any particular
order. Commonly referred to as a Bulleted List.
- Tags:
- <ul>: Indicates the start of an unordered list.
- <li>: Indicates each list item within the unordered list.
- Attributes:
- type: Specifies the type of bullet symbol.
- Values:
- disc (default) - Solid circle
- circle - Hollow circle
- square - Solid square
- none - No bullet, just plain list items
3. Description List
- Purpose: Used to display a list of terms and their associated
descriptions. This is often used for glossaries, or to define terms and their
meanings.
- Tags:
- <dl>: Indicates the start of a description list.
- <dt>: Represents a description term.
- <dd>: Represents a description definition, providing more information
about the term.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>List</title>
</head>
<body>
<h1>List</h1>
<p>here we will learn about list</p>
<hr />
<h2>Unordered List</h2>
<!-- type attribute we are using to change the list style -->
<ul type="circle">
<li>Milk</li>
<li>Tea</li>
<li>Coffee</li>
<li>Sugar</li>
</ul>
<ul type="square">
<li>Milk</li>
<li>Tea</li>
<li>Coffee</li>
<li>Sugar</li>
</ul>
<ul type="none">
<li>Milk</li>
<li>Tea</li>
<li>Coffee</li>
<li>Sugar</li>
</ul>
<h3>Nested List</h3>
<ul>
<l>Science</l>
<ul>
<li>Physics</li>
<li>Chemistry</li>
<li>Bio</li>
</ul>
<li>Arts</li>
<ul>
<li>Geography</li>
<li>History</li>
<li>English</li>
</ul>
<li>Commerce</li>
</ul>
<ol type="a">
<li>Milk</li>
<li>Tea</li>
<li>Coffee</li>
<li>Sugar</li>
</ol>
<ol type="i">
<li>Milk</li>
<li>Tea</li>
<li>Coffee</li>
<li>Sugar</li>
</ol>
<ol type="I">
<li>Milk</li>
<li>Tea</li>
<li>Coffee</li>
<li>Sugar</li>
</ol>
<h2>Description List</h2>
<dl>
<dt>HTML</dt>
<dd>Hyper Text MarkUp language</dd>
</dl>
</body>
</html>
<!-- ! TABLE -->
- An HTML table is used to organize data into rows and columns, providing a
structured layout for displaying information.
- border: Specifies the width of the border around the table and cells. The
default value is 0 (no border).
- cellpadding: Specifies the amount of space between the cell content and
the cell border.
- width and height: Specifies the dimensions of the table. These can be set
in pixels or as a percentage of the containing element.
Merging Cells
- **Anchor Link (Same Page)**: Links to a specific section within the same
page using an ID.
<a href="#heading2">
<p><i>go to heading 2</i></p>
</a>
<a href="./task/resume.html">
go to resume
</a>
<h2>title attribute</h2>
<a href="#link">
<p>go to top</p>
</a>
</body>
</html>
<!-- ! marquee tag -->
Syntax
- Content: The text, images, or other HTML elements that will scroll inside
the <marquee> tag.
- direction:
- Specifies the direction in which the content should scroll.
- Values:
- left (default) → Scrolls content from right to left.
- right → Scrolls content from left to right.
- up → Scrolls content from bottom to top.
- down → Scrolls content from top to bottom.
- behavior:
- Specifies the scrolling behavior of the content.
- Values:
- scroll (default) → Content scrolls continuously.
- slide → Content slides in, then stops.
- alternate → Content alternates back and forth (bounces).
- scrollamount:
- Specifies the speed of the scrolling content.
- Values:
- Any number (default is 6).
- Larger numbers make the content scroll faster.
- loop:
- Specifies how many times the content should scroll.
- Values:
- Any number (default is infinite scrolling).
- height:
- Specifies the height of the marquee container.
- Values:
- Any valid height value (e.g., pixels, percentage).
- width:
- Specifies the width of the marquee container.
- Values:
- Any valid width value (e.g., pixels, percentage).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>Important Alerts</h2>
<audio> Tag
The <audio> tag is used to embed sound content in a webpage, such as music or
other audio files.
- autoplay:
- Automatically starts playing the audio once it loads.
- loop:
- Repeats the audio indefinitely.
- muted:
- Mutes the audio.
<video> Tag
The <video> tag is used to embed video content into a webpage.
- autoplay:
- Automatically plays the video when the page loads.
- loop:
- Repeats the video indefinitely.
- muted:
- Mutes the video by default.
<iframe> Tag
The <iframe> tag is used to embed another HTML document or external content
into the current webpage.
It is often used to embed videos, maps, or other websites.
- frameborder:
- Defines whether the iframe should have a border. 0 for no border and 1 for
border.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multi-Media</title>
</head>
<body>
<h1>we will add audio here </h1>
1. <form>:
- It is a semantic element that defines the beginning of the form.
- It contains all the form-related elements.
Example:
2. <label>:
- Specifies the purpose of the input field.
- It's linked to the <input> field using the for attribute, which matches
the id of the input element.
Example:
<label for="userName">Name:</label>
<input type="text" id="userName">
3. <input>:
- Used to collect user data.
- There are various types such as text, email, password, number, etc.
Example:
Example:
<label for="skills">Skills:</label>
<select id="skills">
<option value="html">HTML</option>
<option value="css">CSS</option>
</select>
5. <optgroup>:
- Groups options together within a dropdown list for better organization.
6. <option>:
- Defines the options within a dropdown list.
7. <fieldset>:
- Groups form elements together and provides a border around them.
Example:
<fieldset>
<legend>Personal Information</legend>
<label for="name">Name:</label>
<input type="text" id="name">
</fieldset>
8. <legend>:
- Provides a caption for the <fieldset> group.
9. <textarea>:
- Used to collect multi-line text input.
- The rows and cols attributes specify the visible height and width.
Example:
Example:
<button type="submit">Submit</button>
Example:
<form action="/submit-data">
2. method: Specifies how the data is sent to the server (GET or POST).
- GET: Sends data in the URL, not secure.
- POST: Sends data securely in the HTTP body.
Example:
<form method="post">
Example:
<form autocomplete="on">
Attributes of the <input> Tag:
1. type: Specifies the type of input field (e.g., text, email, password,
etc.).
2. id: Provides a unique identifier for the input element.
3. name: Associates a name with the input field, used for form submission.
4. value: Defines the initial value of the input field.
5. required: Makes the field mandatory to fill before submission.
6. readonly: Prevents users from modifying the input field value.
7. disabled: Disables the input field.
8. min, max, minlength, maxlength: Used to define the minimum and maximum
values or lengths for input.
9. placeholder: Displays a hint text inside the input field.
10. autofocus: Automatically focuses on the input field when the page loads.
11. step: Specifies the legal number intervals for numeric fields (e.g.,
step="2" means 2, 4, 6, etc.).
The type attribute of the <input> tag in HTML determines the kind of input
field displayed on the webpage. Here are the common values of the type
attribute:
1. text:
- Allows users to enter regular text.
- Default input type.
Example:
<input type="text">
2. email:
- Used for email input. It automatically validates the input for an email
format.
Example:
<input type="email">
3. password:
- Displays input as masked characters (dots or asterisks), hiding the
user's input.
Example:
<input type="password">
4. number:
- Allows users to enter numerical values. It can have min, max, and step
attributes for validation.
Example:
5. tel:
- Allows users to input telephone numbers. It doesn't enforce specific
validation but provides a numeric keyboard on mobile devices.
Example:
<input type="tel">
6. radio:
- Creates a radio button, allowing users to select one op tion from a group.
Example:
7. checkbox:
- Creates a checkbox, allowing users to select multiple options
independently.
Example:
Example:
9. submit:
- Creates a submit button that submits the form data to the server.
Example:
10. reset:
- Resets all the form fields to their default values.
Example:
11. search:
- Creates a search input field, often styled with a "clear" button to
reset the search query.
Example:
<input type="search">
12. date:
- Allows users to select a date using a date picker.
Example:
<input type="date">
13. time:
- Allows users to select a time.
Example:
<input type="time">
14. week:
- Allows users to select a specific week in a year.
Example:
<input type="week">
15. month:
- Allows users to select a specific month and year.
Example:
<input type="month">
16. color:
- Allows users to select a color from a color picker.
Example:
<input type="color">
17. image:
- Creates a submit button in the form of an image.
Example:
18. file:
- Allows users to upload files from their device.
Example:
<input type="file">
19. url:
- Specifies a URL input field. It automatically validates the input for
URL format.
Example:
<input type="url">
20. range:
- Creates a slider input that allows users to select a numeric value
within a specific range.
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Form</title>
</head>
<body>
<h1>Form</h1>
<label for="uemail">Email</label>
<input
type="email"
name="email"
id="uemail"
placeholder="enter your email"
/>
<br /><br />
<label for="upass">Password</label>
<input
type="password"
name="pass"
id="upass"
placeholder="enter password"
minlength="6"
/>
<br /><br />
</fieldset>
<fieldset>
<legend>Personal Info</legend>
<label for="uage">Age</label>
<input type="number" name="" id="uage" /> <br /><br />
<fieldset>
<legend>Timing</legend>
<label for="date">Date</label>
<input type="date" name="" id="date" /> <br /><br />
<label for="time">Time</label>
<input type="time" name="" id="time" /> <br /><br />
<label for="week">Week</label>
<input type="week" name="" id="week" /> <br /><br />
<label for="month">Month</label>
<input type="month" name="" id="month" /> <br /><br />
</fieldset>
<fieldset>
<legend>CheckBox-RadioButton</legend>
<fieldset>
<legend>Select options</legend>
<label for="">Select Subject</label> <br /><br />
<select name="subject" id="">
<optgroup label="Frontend">
<option value="HTML">html</option>
<option value="CSS">css</option>
<option value="JS">javascript</option>
</optgroup>
<optgroup label="backend">
<option value="java">java</option>
<option value="python">python</option>
<option value="c">c</option>
</optgroup>
</select>
</fieldset>
<fieldset>
<legend>buttons</legend>
</form>
</body>
</html>
<!-- ! Inline CSS -->
it is the way of writing the css in same html file by using <style> tag.
selectorName {
propertyName : value ;
propertyName : value;
.
.
.
propertyName:value
}
example :
p {
color:blue;
font-sixe: 20px;
}
<!-- ! external css -->
if we apply inline, internal and external css on the same element. the
inline css will be applyed.
internal and external css has same priority. which one will be at the end
, that will be applyed.
1. Simple Selector
2. Combinator Selector
3. Pseudo Class Selector
4. Pseudo Element Selector
5. Attribute Selector
TagName
Grouping (,)
Universal (*)
Id Name (#)
Class Name (.)
○ It will target all the elements in the document including body tag
too.
○ The symbol used is asterisk (*).
simpleSelector.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>simple selector</title>
<link rel="stylesheet" href="./simpleSelector.css">
</head>
<body>
<div class="box">
<h1>this is h1 tag</h1>
<p id="p1">this is paragraph tag</p>
<p id="p2">this is another paragraph tag</p>
<a href="">this is anchor tag</a>
<p class="para">this is para</p>
<button>click</button>
<button>submit</button>
</div>
<div class="box">
<p class="para" >this is another para in another div</p>
</div>
</body>
</html>
simpleSelector.css
/* ! universal selector */
*{
color:chocolate
}
/* ! tagname selector */
p{
color:red;
}
/* ! id selector */
#p1{
color:blue;
}
/* ! group */
#p2, #p1,button{
color:blue;
}
/* ! class */
.box{
background-color: aqua;
}
.para{
color:red;
}
<!--! Combinator Selector -->
1. Descendent Selector ( )
2. Direct Child Selector (>)
3. Adjacent Sibling Selector (+)
4. General Sibling Selector (~)
<div class="container2">
<p>this is another paragraph</p>
</div>
<p>hiiiiiiiiiiii</p>
</div>
<div class="container3">
<h1>this is heading inside con3</h1>
<p>this is para inside container3</p>
<p id="p1">para-1</p>
<p>para-2</p>
<p>para-3</p>
<p>para-4</p>
<p>para-5</p>
<p>para-6</p>
</div>
</body>
</html>
/* ! descendant selector */
.container3 p{
color:green;
}
.container p{
color:red;
}
.container > p{
color:red;
}
- Characteristics:
- Block-level element: Occupies the full width available.
- Can contain any HTML elements such as text, images, other divs, forms,
etc.
- Useful for dividing a webpage into sections.
- Usage:
- Ideal for creating large structural sections like headers, footers,
content areas, and navigation menus.
- Helps in applying CSS styles and JavaScript functionality to groups of
elements.
- Characteristics:
- Inline-level element: Occupies only the space it needs (doesn't start on a
new line).
- Cannot contain block-level elements (like <div>, <h1>, etc.).
- Mainly used for styling a specific part of the text or inline elements.
- Usage:
- Ideal for applying styles or JavaScript to a small portion of text or
elements within a larger block of content.
- Commonly used within paragraphs (<p>) to style or modify part of the text.
- Definition:
Semantic tags are HTML elements that clearly describe their meaning both to
the browser and to developers.
Unlike non-semantic tags (<div>, <span>), semantic tags provide meaning to the
content enclosed within them.
1. <header>
- Definition: Represents the introductory section or a group of navigation
links in a webpage.
- Usage: Typically contains logo, site name, and navigation elements.
- Example:
<header>
<h1>My Website</h1>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Contact</a>
</nav>
</header>
2. <nav>
- Definition: Represents a section of the page that links to other pages or
to parts within the same page.
- Usage: Usually used for navigation bars or menus.
- Example:
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
3. <main>
- Definition: Represents the main content of the webpage that is unique to
the document, excluding headers, footers, and sidebars.
- Usage: Used for the central content of the webpage.
- Example:
<main>
<h2>Welcome to Our Website</h2>
<p>This is the primary content of the page.</p>
</main>
4. <article>
- Definition: Represents an independent piece of content that could be
independently distributed or reused, such as blog posts, news articles, or
user comments.
- Usage: Used for self-contained, reusable content.
- Example:
<article>
<h3>Blog Post Title</h3>
<p>This is a blog post description.</p>
</article>
5. <section>
- Definition: Represents a generic section of a document or application.
Used to group related content together.
- Usage: Used for thematic grouping of content.
- Example:
<section>
<h2>Our Services</h2>
<p>We provide high-quality services to our customers.</p>
</section>
6. <aside>
- Definition: Represents content that is tangentially related to the
content around it, such as sidebars or pull quotes.
- Usage: Typically used for supplementary content.
- Example:
<aside>
<h4>Related Articles</h4>
<p>Check out these articles for more information.</p>
</aside>
7. <footer>
- Definition: Represents the footer of a section or page, typically
containing copyright information, links to privacy p olicies, or contact
details.
- Usage: Found at the bottom of the page or section.
- Example:
<footer>
<p>© 2024 My Website. All rights reserved.</p>
</footer>
8. <figure>
- Definition: Represents self-contained content, like images, diagrams, or
illustrations, along with their caption.
- Usage: Used for media elements with captions.
- Example:
<figure>
<img src="image.jpg" alt="A beautiful scenery">
<figcaption>Beautiful mountain scenery at sunrise.</figcaption>
</figure>
9. <figcaption>
- Definition: Used to define a caption for a <figure> element.
- Usage: Describes or gives context to the content within the <figure>.
- Example: (See the example for <figure> above)
10. <mark>
- Definition: Represents text that has been highlighted for reference
purposes.
- Usage: Used to emphasize or highlight parts of the text.
- Example:
- Syntax:
<details>
<summary>Click to view more details</summary>
<p>This is additional information that can be toggled. </p>
</details>
12. <summary>
- Definition: The <summary> tag is used inside the <details> tag to provide a
heading or summary of the content that can be toggled.
- Purpose: Acts as a label or title that is clickable, and clicking on it
reveals or hides the associated content.
- Behavior: It is always visible and is used to control the visibility of the
rest of the content within the <details> tag.
- Syntax:
<details>
<summary>Click here for details</summary>
<p>Hidden content goes here.</p>
</details>
<!-- ! Pseudo-Classes Selector -->
The `:hover` pseudo-class applies when the user designates an element (with
some pointing device), but does not activate it. Typically used to change the
appearance of a link when the user hovers over it.
The `:link` pseudo-class applies to links that have not yet been visited.
The `:active` pseudo-class applies during the period in which the element is
being activated (e.g., between the times the user presses the mouse button and
releases it).
<!--? :visited -->
The `:visited` pseudo-class applies once the link has been visited by the
user.
<!-- ! Pseudo-elements Selector -->
### ::before
The `::before` pseudo-element can be used to insert content before the content
of an element. It is often used to add decorative content or icons.
selector::before {
content: "content"; <!--! Required property -->
### ::after
The `::after` pseudo-element can be used to insert content after the content
of an element. It is often used to add decorative content or to clear floats.
selector::after {
content: "content"; <!--! Required property -->
### ::first-line
The `::first-line` pseudo-element applies styles to the first line of a block -
level element. It is useful for creating drop caps or emphasizing the first
line of text.
### ::first-letter
The `::first-letter` pseudo-element applies styles to the first letter of a
block-level element. It is often used to create drop caps.
### ::selection
The `::selection` pseudo-element applies styles to the portion of a document
that has been highlighted by the user (e.g., selected with the mouse).
### ::marker
The `::marker` pseudo-element is used to style the marker box of a list item
(i.e., the bullet points or numbers).
**Example:**
p:hover::first-letter {
color: red;
}
1.MM(milli meter)
2.CM(Centi-meter)
3.Px(Pixel)
<!--? 1. % -->
<!--? 2. vw -->
<!--? 3. vh -->
Font Properties:
1. font-style
2. font-weight
3. font-size
4. font-family
Text properties in CSS are used to control the appearance and formatting of
text on a webpage.
These properties allow you to modify various aspects of the text, such as its
color, size, spacing, alignment, decoration, and transformation.
Text Alignment:
text-align:
Text Decoration:
text-decoration:
text-decoration-line:
text-decoration-color:
text-decoration-style:
text-indent:
Text Transformation:
text-transform:
- Controls the capitalization of text.
- Values: none, capitalize, uppercase, lowercase.
Text Shadow:
text-shadow:
- Adds shadow to text.
- Values: none or a combination of h-shadow, v-shadow, blur-radius, and
color.
letter-spacing:
- Sets the spacing between characters.
- Values: length values (px, em, etc.).
word-spacing:
- Sets the spacing between words.
- Values: length values (px, em, etc.).
line-height:
- The line-height property is used to specify the space between lines:
- A line height of 1.5 means the space between lines is 1.5 times the font
size.
#### Definition:
- The CSS box model represents the structure of an element in terms of its
content, padding, border, and margin.
1. **Content**:
- The actual content of the element, such as text, images, or other media.
- Example: `width` and `height` properties define the size of the
content area.
2. **Padding**:
3. **Border**:
4. **Margin**:
- The space outside the border, separating the element from adjacent
elements.
- Example: `margin: 10px;` (applies margin equally to all sides).
2. **Padding**:
- Can be set individually for each side: `padding-top`, `padding-right`,
`padding-bottom`, `padding-left`.
- Example: `padding: 10px 20px 30px 40px;` (top, right, bottom, left).
3. **Border**:
- Can be set individually for each side: `border-top`, `border-right`,
`border-bottom`, `border-left`.
- Example: `border: 2px dashed red;` (applies to all sides).
- Detailed properties: `border-width`, `border-style`, `border-color`.
4. **Margin**:
- Can be set individually for each side: `margin-top`, `margin-right`,
`margin-bottom`, `margin-left`.
- Example: `margin: 5px 10px;` (top/bottom, right/left).
- **`box-sizing`**:
- Defines how the total width and height of an element are calculated.
- `content-box` (default): width and height include only the content.
- `border-box`: width and height include content, padding, and border.
- Example: `box-sizing: border-box;`.
<!-- ! Border Property -->
#### Definition:
- The `border` property in CSS is used to define the border around an element.
1. **`border-width`**:
- Example:
```css
border-width: 2px;
border-width: 2px 4px 6px 8px; /* top right bottom left */
```
2. **`border-style`**:
4. **`border-radius`**:
5. **`border`** (Shorthand):
- Example:
```css
border-top: 5px solid red;
border-right: 10px dashed blue;
border-bottom: 3px dotted green;
border-left: 2px double yellow;
```
<!-- ! FlexBox -->
#### Definition:
- Flexbox is a CSS layout model that allows you to design a flexible and
responsive layout structure without using positioning.
1. **`display: flex;`**:
- Defines a flex container, enabling flex context for all its direct
children.
2. **`flex-direction`**:
3. **`flex-wrap`**:
5. **`align-items`**:
- Aligns flex items along the cross axis (vertically if `flex-direction:
row;`).
- Values:
- `stretch`: Default, items stretch to fill the container.
- `flex-start`: Items align to the start of the cross axis.
- `flex-end`: Items align to the end of the cross axis.
- `center`: Items align at the center of the cross axis.
6. **`align-content`**:
- Aligns flex lines when there's extra space in the cross axis.
- Values (similar to `justify-content` but applied to multiple lines):
- `flex-start`, `flex-end`, `center`, `space-between`, `space-around`,
`stretch`.
1. **`order`**:
2. **`flex-grow`**:
3. **`flex-shrink`**:
4. **`flex-basis`**:
5. **`align-self`**:
1. **`background-color`**:
```css
background-color: lightblue;
```
2. **`background-image`**:
```css
background-image: url('image.png');
```
3. **`background-repeat`**:
```css
background-repeat: no-repeat;
```
4. **`background-position`**:
```css
background-position: 100% 100%;
```
5. **`background-size`**:
```css
background-size: cover;
```
6. **`background-attachment`**:
```css
background-attachment: fixed;
Project Code For Background
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Background Project</title>
<link rel="stylesheet" href="./task.css">
</head>
<body>
<section id="section-1">
<div>
<h1>this section1</h1>
<p>this is para</p>
</div>
</section>
<section id="section-2">
<div>
<h1>this is section2</h1>
<p>this is para</p>
</div>
</section>
<section id="section-3">
<div>
<h1>this is section3</h1>
<p>this is para</p>
</div>
</section>
<section id="section-4">
<div>
<h1>this is section4</h1>
<p>this is para</p>
</div>
</section>
</body>
</html>
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
section {
width: 100%;
height: 100vh;
background-image: url("https://images.pexels.com/photos/189349/pexels -
photo-189349.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" );
background-repeat: no-repeat;
background-size: 100% 100%;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
background-attachment: fixed;
}
section>div> h1{
color: white;
font-size: 64px;
text-transform: capitalize;
font-weight: bold;
text-shadow: 2px 2px 5px #181818;
}
section>div> p{
color: #fff;
font-size: 40px;
text-transform: capitalize;
text-shadow: 2px 2px 5px #212121;
}
#section-2{
background-image: url("https://images.pexels.com/photos/994605/pexels -
photo-994605.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" );
}
#section-3{
background-image: url('https://images.pexels.com/photos/38136/pexels -
photo-38136.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1');
}
#section-4{
background-image: url('https://images.pexels.com/photos/1482193/pexels -
photo-1482193.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1' );
}
<!-- ! overflow -->
The overflow property in CSS controls how content is handled when it overflows
its containing element's box.
This is particularly important when dealing with elements that have a fixed
size, such as divs, where the content may extend beyond the boundaries of the
element.
# Syntax
overflow: visible | hidden | scroll | auto ;
Values
1. visible (default)
- Example:
.box {
overflow: visible;
}
2. hidden
- Example:
.box {
overflow: hidden;
}
3. scroll
- Example:
.box {
overflow: scroll;
}
4. auto
- Example:
.box {
overflow: auto;
}
<!-- ! Color -->
RGBA color values are an extension of RGB color values with an alpha, channel
which specifics the opacity of the object.
An RGBA color is specified with rgba() function.
Syntax: rgba(red, green, blue, alpha).
The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully
opaque).
HSL stands for hue, saturation, and lightness and represents a cylindrical -
coordinate representation of colors.
An HSL color value is specified with hsl() function.
HSLA color values are an extension of HSL color values with an alpha, channel
which specifics the opacity of the object.
An HSLA color value is specified with hsla() function.
Syntax: hsla(hue, saturation, lightness, alpha).
The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully
opaque).
<!--? HEXADECIMAL COLOR -->
1. **`static`** (default):
- The default positioning for all HTML elements.
- Elements are positioned according to the normal document flow
- `top`, `right`, `bottom`, `left`, and `z-index` properties do not apply.
**Example**:
```css
div {
position: static;
}
```
2. **`relative`**:
**Example**:
```css
div {
position: relative;
top: 20px;
left: 10px;
}
```
In this example, the `div` is shifted 20px down and 10px to the right from
where it would normally be positioned.
3. **`absolute`**:
- The element is removed from the normal document flow and positioned
relative to its nearest positioned ancestor (i.e., an ancestor with a
`relative`, `absolute`, or `fixed` position).
- If no such ancestor exists, it is positioned relative to the initial
containing block (usually the viewport).
- `top`, `right`, `bottom`, and `left` properties are used to position the
element.
**Example**:
```css
div {
position: absolute;
top: 50px;
left: 30px;
}
```
In this example, the `div` is positioned 50px from the top and 30px from
the left of its nearest positioned ancestor.
4. **`fixed`**:
- The element is removed from the normal document flow and positioned
relative to the viewport.
- The element stays fixed in position even when the page is scrolled.
- `top`, `right`, `bottom`, and `left` properties are used to position the
element.
**Example**:
```css
div {
position: fixed;
top: 10px;
right: 10px;
}
```
In this example, the `div` remains fixed 10px from the top and right of the
viewport, even when the page is scrolled.
5. **`sticky`**:
**Example**:
```css
div {
position: sticky;
top: 0;
}
```
In this example, the `div` will stick to the top of the viewport once the
user scrolls past it.
**Example**:
```css
div {
position: absolute;
z-index: 1;
}
```
<!-- ! transition -->
Syntax
1. property
- Example:
transition: background-color 0.5s ease;
2. duration
- Example:
transition: background-color 1s;
3. timing-function
- Common Values:
- ease: Starts slow, then fast, then ends slow (default value).
- linear: Constant speed from start to end.
- ease-in: Starts slow, then fast.
- ease-out: Starts fast, then slow.
- ease-in-out: Starts slow, speeds up, then slows down.
- Example:
transition: width 2s ease-in;
4. delay
Example:
Definition:
Transform Functions:
1. translate():
2. rotate():
- Example: transform: scale(2, 1.5); (doubles the width and increases the
height by 50%).
4. skew():
Transform Origin:
- transform-origin:
- Defines the point around which the transformation occurs.
- Can be set using values like center, top, bottom, left, right, or specific
coordinates.
- Example: transform-origin: top;
<!-- ! animation -->
- CSS Animations allow you to create smooth transitions and dynamic effects by
animating changes to CSS properties over time.
1. **`@keyframes` Rule**:
- Defines the stages of the animation and the styles at each stage.
- You can specify the styles at different percentages of the animation's
duration or use keywords like `from` (equivalent to `0%`) and `to` (equivalent
to `100%`).
- **Example**:
```css
@keyframes slideIn {
from {
transform: translateX(-100%);
}
to {
transform: translateX(0);
}
}
```
2. **Animation Properties**:
3. **Shorthand Property**:
- The `animation` property can be used to set all the animation properties
in one line.
- **Syntax**: `animation: name duration timing-function delay iteration-
count direction fill-mode play-state;`
- **Example**:
```css
.box {
animation: slideIn 2s ease-in-out 1s infinite alternate forwards;
}
```
<!-- ! media query -->
#### Definition:
- **Media queries** are a CSS technique that allows you to apply styles to
elements based on the characteristics of the device or screen displaying the
content. They are essential for creating responsive web designs that adapt to
different screen sizes, orientations, and resolutions.
```css
@media (condition) {
/* CSS rules here */
}
```
2. **Orientation**:
- **`orientation: portrait`**: Targets devices with a portrait orientation
(height is greater than width).
- **`orientation: landscape`**: Targets devices with a landscape
orientation (width is greater than height).
- **Example**:
```css
@media (orientation: landscape) {
/* Styles for landscape mode */
}
```
#### we can also give range for applying media query :
- **Example**:
```css
@media (min-width: 600px) and (max-width: 1200px) {
/* Styles for screens between 600px and 1200px wide */
}
```