Amity School of Engineering & Technology: CSS Lecture

CSS
Lecture 11
CSS
CSS is a language for specifying how documents
are presented to users — how they are styled,
laid out, etc.
document
 is usually a text file structured
using a 
markup language
 — 
HTML
 is the most
common markup language, but you will also
come across other markup languages such
as 
SVG
 or 
XML
.
CSS
Presenting
 a document to a user means
converting it into a usable form for your
audience. 
Browsers
,like 
Firefox
Chrome
 or 
Intern
et Explorer
, are designed to present documents
visually, for example, on a computer screen,
projector or printer.
Cascading Style Sheet
CSS code is simple written instructions that
tell web browsers. How to display things on a
page.
For Example
make text bold.
position things a page.
set the font style for a page or paragraph etc.
How does CSS affect HTML?
Web browsers apply 
CSS rules
 to a document
to affect how they are displayed.
A CSS rule is formed from:
A set of 
properties
, which have values set to
update how the HTML content is displayed,
for example 
I want my element's width to be 50% of
its parent element, and its background to be red
.
Cont..
selector
, which 
selects
 the element(s) you
want to apply the updated property values to.
For example, 
I want to apply my CSS rule to all the
paragraphs in my HTML document
.
A set of CSS rules contained within
stylesheet
 determines how a webpage
should look
How does CSS actually work?
When a browser displays a document, it must
combine the document's content with its style
information. It processes the document in two
stages:
Cont..
1.
The browser converts 
HTML
 and 
CSS
 into
the 
DOM
 (
Document Object Model
). The DOM
represents the document in the computer's
memory. It combines the document's content
with its style.
2.
The browser displays the contents of the
DOM.
Cont..
 
Load
HTML
Parse
HTML
Create
DOM tree
Display
Load
CSS
Parse
CSS
Attached Style to
DOM  node
HTML CODE
<p> Let's use:
<span>Cascading</span>
<span>Style</span>
<span>Sheets</span>
</p>
In DOM
P
    
├─
 "Let's use:"
    
├─
 SPAN
     |       
└─
 "Cascading"
     
├─
 SPAN
     | 
└─
 "Style"
      
└─
 SPAN
            
└─
 "Sheets"
How to apply your CSS to your HTML
There are three different ways to apply CSS to
an HTML document.
1.
Inline
2.
Internal
3.
External
Inline
Inline styles
 are CSS declarations that affect
one element only, contained within
style
 attribute:
Example
<html>
     <head>
     <title>My CSS experiment</title>
     </head>
     <body>
     <h1 style="color: blue; background-color:
           yellow; border: 1px solid black;">Hello World!
     </h1>
     <p style="color:red;">This is my first CSS example
     </p>
     </body>
 </html>
Internal
<
html>
         <head>
         <title>My CSS experiment</title>
          <style>
          h1
         {
           color: blue;
           background-color: yellow;
           border: 1px solid black;
          }
           P
          {
           color: red;
          }
           </style>
           </head>
           <body>
          <h1>Hello World!</h1>
          <p>This is my first CSS example</p>
          </body>
</html>
External
An external stylesheet is when you have your
CSS written in a separate file with
a .css extension, and you reference it from an
HTML 
<link>
 element.
Example HTML FILE
<html>
    <head>
    <title>My CSS experiment</title>
    <link rel="stylesheet" href="style.css">
    </head>
      <body>
      <h1>Hello World!</h1>
        <p>This is my first CSS example</p>
       </body>
</html>
CSS File
h1
     {
     color: blue;
     background-color: yellow;
    border: 1px solid black;
      }
     p
      {
      color: red;
      }
What is DOM
A DOM has a tree-like structure. Each element,
attribute and piece of text in the markup language
becomes a 
DOM node
 in the tree structure. The
nodes are defined by their relationship to other
DOM nodes. Some elements are parents of child
nodes, and child nodes have siblings.
Understanding the DOM helps you design, debug
and maintain your CSS because the DOM is where
your CSS and the document's content meet up.
Slide Note
Embed
Share

In this lecture series, the Amity School of Engineering & Technology delves into the intricacies of CSS, explaining how this language influences the presentation of web documents. From basic concepts to practical applications, discover how CSS impacts HTML and shapes the visual display of online content.

  • Amity School
  • Engineering
  • Technology
  • CSS
  • Web Development

Uploaded on Mar 05, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Amity School of Engineering & Technology CSS Lecture 11

  2. Amity School of Engineering & Technology CSS CSS is a language for specifying how documents are presented to users how they are styled, laid out, etc. A document is usually a text file structured using a markup language HTML is the most common markup language, but you will also come across other markup languages such as SVG or XML.

  3. Amity School of Engineering & Technology CSS Presenting converting it into a usable form for your audience. Browsers,like Firefox, Chrome or Intern et Explorer, are designed to present documents visually, for example, on a computer screen, projector or printer. a document to a user means

  4. Amity School of Engineering & Technology Cascading Style Sheet CSS code is simple written instructions that tell web browsers. How to display things on a page. For Example make text bold. position things a page. set the font style for a page or paragraph etc.

  5. Amity School of Engineering & Technology How does CSS affect HTML? Web browsers apply CSS rules to a document to affect how they are displayed. A CSS rule is formed from: A set of properties, which have values set to update how the HTML content is displayed, for example I want my element's width to be 50% of its parent element, and its background to be red.

  6. Amity School of Engineering & Technology Cont.. A selector, which selects the element(s) you want to apply the updated property values to. For example, I want to apply my CSS rule to all the paragraphsinmyHTMLdocument. A set of CSS rules a stylesheet determines how a webpage should look contained within

  7. Amity School of Engineering & Technology How does CSS actually work? When a browser displays a document, it must combine the document's content with its style information. It processes the document in two stages:

  8. Amity School of Engineering & Technology Cont.. 1. The browser converts HTML and CSS into the DOM (Document Object Model). The DOM represents the document in the computer's memory. It combines the document's content with its style. 2. The browser displays the contents of the DOM.

  9. Amity School of Engineering & Technology Cont.. Load HTML Parse HTML Create DOM tree Display Attached Style to DOM node Load CSS Parse CSS

  10. Amity School of Engineering & Technology HTML CODE <p> Let's use: <span>Cascading</span> <span>Style</span> <span>Sheets</span> </p>

  11. Amity School of Engineering & Technology In DOM P "Let's use:" SPAN | "Cascading" SPAN | "Style" SPAN "Sheets"

  12. Amity School of Engineering & Technology How to apply your CSS to your HTML There are three different ways to apply CSS to an HTML document. 1. Inline 2. Internal 3. External

  13. Amity School of Engineering & Technology Inline Inline styles are CSS declarations that affect one element only, a style attribute: contained within

  14. Amity School of Engineering & Technology Example <html> <head> <title>My CSS experiment</title> </head> <body> <h1 style="color: blue; background-color: yellow; border: 1px solid black;">Hello World! </h1> <p style="color:red;">This is my first CSS example </p> </body> </html>

  15. Amity School of Engineering & Technology Internal <html> <head> <title>My CSS experiment</title> <style> h1 { color: blue; background-color: yellow; border: 1px solid black; } P { color: red; } </style> </head> <body> <h1>Hello World!</h1> <p>This is my first CSS example</p> </body> </html>

  16. Amity School of Engineering & Technology External An external stylesheet is when you have your CSS written in a separate file with a .css extension, and you reference it from an HTML <link> element.

  17. Amity School of Engineering & Technology Example HTML FILE <html> <head> <title>My CSS experiment</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>Hello World!</h1> <p>This is my first CSS example</p> </body> </html>

  18. Amity School of Engineering & Technology CSS File h1 { color: blue; background-color: yellow; border: 1px solid black; } p { color: red; }

  19. Amity School of Engineering & Technology What is DOM A DOM has a tree-like structure. Each element, attribute and piece of text in the markup language becomes a DOM node in the tree structure. The nodes are defined by their relationship to other DOM nodes. Some elements are parents of child nodes, and child nodes have siblings. Understanding the DOM helps you design, debug and maintain your CSS because the DOM is where your CSS and the document's content meet up.

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#