Guest User

Untitled

a guest
Jul 14th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. HTML is a language used on webpages, its pretty much just tags. To start a tag use <html>, to end it </html>
  2.  
  3. There are a tonne of different tags, here's a reference list: https://www.w3schools.com/TAGs/default.asp
  4.  
  5. Not all of these are used often, there are quite a few I've never had to use after 2 years of web development.
  6.  
  7. Think of these tags as boxes, <html></html> is just a very big box, <header></header> is a smaller box inside of the HTML-box.
  8.  
  9. ALWAYS close a tag in the same parent tag as you opened them, ex. <html><header></header></html> is the proper way, DONT DO <html><header></html></header>. Although most browsers are lenient in this, please, just don't. It causes confusion and bugs in browsers which aren't as lenient.
  10.  
  11. To start using HTML:
  12. Open notepad or whatever code editor you prefer (I recommend Atom or Notepad++) and create a new file, add the following
  13.  
  14. <!doctype html> <-- This line tells the browser "Hey! HTML5 here!"
  15. <html> <-- Opens the HTML box
  16. <body> <-- Stuff inside the body-tags is whats supposed to be seen on the page
  17. Hello world!
  18. </body> <-- Closes the body text
  19. </html> <-- Closes the HTML tag
  20.  
  21. Save this as page.html (the .html extension is what makes it behave as a webpage) and open it in your browser (doubleclicking the in file explorer should open the file in your default browser)
  22.  
  23. Since HTML is (pretty much) useless without CSS, here's a very simple crash course for CSS. CSS is the way you paint your boxes made with HTML. Lets say I use <div></div> in HTML, you would select it in CSS with:
  24.  
  25. div {
  26. /* CSS STYLES GO HERE */
  27. }
  28.  
  29. If I were to make the div red I would do:
  30.  
  31. div {
  32. background: red;
  33. }
  34.  
  35. To use CSS in your webpage in the most basic way:
  36. <!doctype html>
  37. <html>
  38. <head> <-- The head tag is used for info the browser needs to render the page properly
  39. <style> <-- Your CSS goes in this tag
  40. div {
  41. background: red;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. Hello world!
  47. </body>
  48. </html>
  49.  
  50. Now, before you can see the element(a box is usually refered to as an element) on the screen you have to either put some text in it or set the width and height with CSS.
  51.  
  52. Text:
  53. <div>
  54. Hello
  55. </div>
  56.  
  57. width + height in CSS:
  58. div {
  59. background: red;
  60. height: 50px;
  61. width: 50px;
  62. }
  63.  
  64. If you, lets say have 2 div elements which you want to have different backgrounds you'd use classes or ID's. The difference between the two is that you can reuse classes, ID's are a 1 time use (again, browsers would probably work if you used an ID for two different elements, but you shouldnt reuse them)
  65.  
  66. HTML:
  67. <div>
  68. Element one!
  69. </div>
  70.  
  71. <div>
  72. Element two!
  73. </div>
  74.  
  75. Now, to select the elements individually, add an ID in the opening tag:
  76.  
  77. <div id="first">
  78. Element one!
  79. </div>
  80.  
  81. <div id="second">
  82. Element two!
  83. </div>
  84.  
  85. Yay! They can now be selected in CSS based on their ID!
  86.  
  87. #first {
  88. background: blue;
  89. }
  90.  
  91. #second {
  92. background: red;
  93. }
  94.  
  95. The # indicates you want an element with the id to be selected
  96.  
  97.  
  98. Now they both need a width and height so we can see them on the page, give both elements a class:
  99.  
  100. <div id="first" class="box">
  101. Element one!
  102. </div>
  103.  
  104. <div id="second" class="box">
  105. Element two!
  106. </div>
  107.  
  108. Then add CSS for it
  109.  
  110. .box {
  111. width: 50px;
  112. height: 50px;
  113. }
  114.  
  115. Now both elements are displayed on the page with different backgrounds! Hooray!
Advertisement
Add Comment
Please, Sign In to add comment