Skip to content

Instantly share code, notes, and snippets.

@hiba-machfej
Forked from tech-chieftain/DOM.md
Created August 8, 2023 08:30
Show Gist options
  • Save hiba-machfej/b9b662a84ed51cb04209dd5e7acc7df1 to your computer and use it in GitHub Desktop.
Save hiba-machfej/b9b662a84ed51cb04209dd5e7acc7df1 to your computer and use it in GitHub Desktop.

Questions: Frontend File Setup

Answer the following questions with your group:

  • How do you link a JavaScript file to an HTML document?
  • How do you link a CSS file to an HTML document?
  • What are the roles of HTML, CSS, and JavaScript on a webpage?
  • What is the DOM? How is it related to HTML, CSS, and JavaScript?
  • How does HTML get rendered into DOM?
  • What are elements?
  • What are attributes in HTML?
  • How can we interact with HTML?
@hasnahadd
Copy link

  1. to link js to html using script tag <script src="myscripts.js"></script>
  2. to link css to html using link rel
  3. html is for the structure of the website, css for the design makes the website colourful also controls the visual styling and layout and the and the js make it functional
  4. The Document Object Model (DOM) is a programming interface that represents the structured elements of a web page u can think as a middle layer between the user and the underline html css js ...when a web page is loaded, the browser first reads the HTML text and constructs DOM Tree from it. Then it processes the CSS whether that is inline, embedded, or external CSS and constructs the CSSOM Tree from it. After these trees are constructed, then it constructs the Render-Tree from it. its helps to manipulate the website and make it dynamic
  5. when a web page is loaded, the browser first reads the HTML text and constructs DOM Tree from it.
  6. Elements are the building blocks of web pages, defined in HTML using tags.
  7. They provide additional information about elements , They're used within opening tags

@liliumorion
Copy link

1- we link a JavaScript file to an HTML document using the <script> element: <script src="index.js"></script>.
2- we link a CSS file to an HTML document using the element: <link href="style.css"rel="stylesheet" >
3- the roles of HTML, CSS & JavaScript are as follows:
- HTML offers the core skeleton of a webpage.
-CSS controls the presentation and styling of it.
-JavaScript enables interactivity & dynamic behavior on it as well.
4- The DOM is a programming interface. it's a way web browsers organize & represent web pages in a structured hierarchical tree, allowing scripts like JS to access and modify the page in real time.
5- HTML gets rendered into the DOM by going through a process that we can simplify to the following:
-Parsing HTML, which means breaking down the HTML code into a structured format that the browser can understand.
-Creating the DOM Tree, in a hierarchical tree-like structure, where each HTML element becomes a node in this tree, and text within it becomes text nodes, while still respecting the order and the parent-child hierarchy.
-Styling, by applying CSS styles associated with the HTML elements.
-Rendering, which happens once the DOM tree is made, and that's when the browser uses the information from HTML, CSS & JS to render the web page on the screen.
6- an HTML element is a section that's enclosed within start and end tags and contains content between them.
7- HTML attributes are additional information that modifies the behavior or provides additional information about our elements.
8- interacting with HTML can occur in different ways, mainly using JS, frameworks, libraries etc..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment