Advertisement
Guest User

html.txt

a guest
Apr 5th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.14 KB | None | 0 0
  1. - The <!DOCTYPE html> declaration defines this document to be HTML5
  2. - The <html> element is the root element of an HTML page
  3. - The <head> element contains meta information about the document
  4. - The <title> element specifies a title for the document
  5. - The <body> element contains the visible page content
  6. - The <h1> element defines a large heading
  7. - The <p> element defines a paragraph
  8.  
  9. HTML images are defined with the <img> tag.
  10. The source file (src), alternative text (alt), width, and height are provided as attributes.
  11.  
  12. HTML buttons are defined with the <button> tag.
  13.  
  14. HTML lists are defined with the <ul> (unordered/bullet list) or the <ol> (ordered/numbered list) tag, followed by <li> tags (list items):
  15.  
  16. HTML elements with no content are called empty elements. <br>
  17.  
  18. HTML links are defined with the <a> tag. The link address is specified in the href attribute.
  19.  
  20. The alt attribute specifies an alternative text to be used, when an image cannot be displayed.
  21.  
  22. The style attribute is used to specify the styling of an element, like color, font, size etc.
  23. <p style="color:red">I am a paragraph</p>
  24.  
  25. The language of the document can be declared in the <html> tag.
  26.  
  27. The language is declared with the lang attribute.
  28. <html lang="en-US">
  29.  
  30. Here, a title attribute is added to the <p> element. The value of the title attribute will be displayed as a tooltip when you mouse over the paragraph
  31. <p title="I'm a tooltip">
  32.  
  33. Search engines use the headings to index the structure and content of your web pages. Search engines use the headings to index the structure and content of your web pages.
  34. Each HTML heading has a default size. However, you can specify the size for any heading with the style attribute, using the CSS font-size property.
  35.  
  36.  
  37. The <hr> tag defines a thematic break in an HTML page, and is most often displayed as a horizontal rule.
  38.  
  39. The HTML <head> element has nothing to do with HTML headings.
  40. The <head> element is a container for metadata. HTML metadata is data about the HTML document. Metadata is not displayed.
  41. The <head> element is placed between the <html> tag and the <body> tag:
  42.  
  43.  
  44. The HTML <br> element defines a line break.
  45.  
  46. The HTML <pre> element defines preformatted text.
  47. The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks:
  48.  
  49. Setting the style of an HTML element, can be done with the style attribute.
  50. The HTML style attribute has the following syntax:
  51. <tagname style="property:value;">
  52. The property is a CSS property. The value is a CSS value.
  53.  
  54. The background-color property defines the background color for an HTML element.
  55. The color property defines the text color for an HTML element:
  56. The font-size property defines the text size for an HTML element:
  57. The text-align property defines the horizontal text alignment for an HTML element:
  58.  
  59.  
  60. HTML also defines special elements for defining text with a special meaning.
  61. HTML uses elements like <b> and <i> for formatting output, like bold or italic text.
  62. Formatting elements were designed to display special types of text:
  63.  
  64. <b> - Bold text
  65. <strong> - Important text
  66. <i> - Italic text
  67. <em> - Emphasized text
  68. <mark> - Marked text
  69. <small> - Small text
  70. <del> - Deleted text
  71. <ins> - Inserted text
  72. <sub> - Subscript text
  73. <sup> - Superscript text
  74.  
  75. The HTML <q> element defines a short quotation.
  76. The HTML <blockquote> element defines a section that is quoted from another source.
  77. <blockquote cite="http://www.worldwildlife.org/who/index.html">quote</blockquote>
  78.  
  79. The HTML <abbr> element defines an abbreviation or an acronym.
  80. <p>The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>
  81.  
  82. The HTML <address> element defines contact information (author/owner) of a document or an article.
  83.  
  84. The HTML <cite> element defines the title of a work.
  85.  
  86. The HTML <bdo> element defines bi-directional override.
  87.  
  88.  
  89. You can add comments to your HTML source by using the following syntax:
  90. <!-- Write your comments here -->
  91.  
  92.  
  93. CSS stands for Cascading Style Sheets.
  94. CSS describes how HTML elements are to be displayed on screen, paper, or in other media.
  95. CSS can be added to HTML elements in 3 ways:
  96.  
  97. Inline - by using the style attribute in HTML elements
  98. Internal - by using a <style> element in the <head> section
  99. External - by using an external CSS file </style>
  100.  
  101. An inline CSS is used to apply a unique style to a single HTML element.
  102. <h1 style="color:blue;">This is a Blue Heading</h1>
  103.  
  104. An internal CSS is used to define a style for a single HTML page.
  105. <style>
  106. body {background-color: powderblue;}
  107. h1 {color: blue;}
  108. p {color: red;}
  109. </style>
  110.  
  111. An external style sheet is used to define the style for many HTML pages.
  112. With an external style sheet, you can change the look of an entire web site, by changing one file!
  113. To use an external style sheet, add a link to it in the <head> section of the HTML page:
  114.  
  115. <head>
  116. <link rel="stylesheet" href="styles.css">
  117. </head>
  118.  
  119. The CSS color property defines the text color to be used.
  120.  
  121. The CSS font-family property defines the font to be used.
  122.  
  123. The CSS font-size property defines the text size to be used.
  124.  
  125. The CSS border property defines a border around an HTML element.
  126.  
  127. The CSS padding property defines a padding (space) between the text and the border.
  128.  
  129. The CSS padding property defines a padding (space) between the text and the border.
  130.  
  131. To define a specific style for one special element, add an id attribute to the element.
  132.  
  133. To define a style for a special type of elements, add a class attribute to the element.
  134.  
  135. External style sheets can be referenced with a full URL or with a path relative to the current web page.
  136. <link rel="stylesheet" href="https://www.w3schools.com/html/styles.css">
  137.  
  138. In HTML, links are defined with the <a> tag:
  139. <a href="url">link text</a>
  140.  
  141. HTML Link Colors
  142. By default, a link will appear like this (in all browsers):
  143.  
  144. An unvisited link is underlined and blue
  145. A visited link is underlined and purple
  146. An active link is underlined and red
  147. You can change the default colors, by using CSS:
  148. <style>
  149. a:link {
  150. color: green;
  151. background-color: transparent;
  152. text-decoration: none;
  153. }
  154.  
  155. a:visited {
  156. color: pink;
  157. background-color: transparent;
  158. text-decoration: none;
  159. }
  160.  
  161. a:hover {
  162. color: red;
  163. background-color: transparent;
  164. text-decoration: underline;
  165. }
  166.  
  167. a:active {
  168. color: yellow;
  169. background-color: transparent;
  170. text-decoration: underline;
  171. }
  172. </style>
  173.  
  174.  
  175. The target attribute specifies where to open the linked document.
  176. The target attribute can have one of the following values:
  177.  
  178. _blank - Opens the linked document in a new window or tab
  179. _self - Opens the linked document in the same window/tab as it was clicked (this is default)
  180. _parent - Opens the linked document in the parent frame
  181. _top - Opens the linked document in the full body of the window
  182. framename - Opens the linked document in a named frame
  183.  
  184. It is common to use images as links:
  185. <a href="default.asp">
  186. <img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;border:0;">
  187. </a>
  188.  
  189. The title attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves over the element.
  190. <a href="https://www.w3schools.com/html/" title="Go to W3Schools HTML section">Visit our HTML Tutorial</a>
  191.  
  192. Image Maps
  193. Use the <map> tag to define an image-map. An image-map is an image with clickable areas.
  194.  
  195. <img src="workplace.jpg" alt="Workplace" usemap="#workmap">
  196.  
  197. <map name="workmap">
  198. <area shape="rect" coords="34,44,270,350" alt="Computer" href="computer.htm">
  199. <area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm">
  200. <area shape="circle" coords="337,300,44" alt="Coffee" href="coffee.htm">
  201. </map>
  202.  
  203.  
  204. HTML5 introduced the <picture> element to add more flexibility when specifying image resources.
  205. The <picture> element contains a number of <source> elements, each referring to different image sources. This way the browser can choose the image that best fit the current view and/or device.
  206. Each <source> element have attributes describing when their image is the most suitable.
  207. The browser will use the first <source> element with matching attribute values, and ignore any following <source> elements.
  208.  
  209. <picture>
  210. <source media="(min-width: 650px)" srcset="img_pink_flowers.jpg">
  211. <source media="(min-width: 465px)" srcset="img_white_flower.jpg">
  212. <img src="img_orange_flowers.jpg" alt="Flowers" style="width:auto;">
  213. </picture>
  214.  
  215. An HTML table is defined with the <table> tag.
  216.  
  217. Each table row is defined with the <tr> tag. A table header is defined with the <th> tag. By default, table headings are bold and centered. A table data/cell is defined with the <td> tag.
  218.  
  219. If you do not specify a border for the table, it will be displayed without borders.
  220. A border is set using the CSS border property:
  221. table, th, td {
  222. border: 1px solid black;
  223. }
  224.  
  225. If you want the borders to collapse into one border, add the CSS border-collapse property:
  226. table, th, td {
  227. border: 1px solid black;
  228. border-collapse: collapse;
  229. }
  230.  
  231. To set the padding, use the CSS padding property.
  232. To left-align the table headings, use the CSS text-align property.
  233. To set the border spacing for a table, use the CSS border-spacing property.
  234.  
  235. To make a cell span more than one column, use the colspan attribute:
  236.  
  237. <table style="width:100%">
  238. <tr>
  239. <th>Name</th>
  240. <th colspan="2">Telephone</th>
  241.  
  242. To make a cell span more than one row, use the rowspan attribute.
  243.  
  244. To make a cell span more than one row, use the rowspan attribute.
  245.  
  246. To define a special style for a special table, add an id attribute to the table.
  247.  
  248. LIST
  249. The CSS list-style-type property is used to define the style of the list item marker:
  250.  
  251. Value Description
  252. disc Sets the list item marker to a bullet (default)
  253. circle Sets the list item marker to a circle
  254. square Sets the list item marker to a square
  255. none The list items will not be marked
  256.  
  257. The CSS list-style-type property is used to define the style of the list item marker:
  258.  
  259. Value Description
  260. disc Sets the list item marker to a bullet (default)
  261. circle Sets the list item marker to a circle
  262. square Sets the list item marker to a square
  263. none The list items will not be marked
  264.  
  265. HTML also supports description lists.
  266.  
  267. A description list is a list of terms, with a description of each term.
  268.  
  269. The <dl> tag defines the description list, the <dt> tag defines the term (name), and the <dd> tag describes each term:
  270. <dl>
  271. <dt>Coffee</dt>
  272. <dd>- black hot drink</dd>
  273. <dt>Milk</dt>
  274. <dd>- white cold drink</dd>
  275. </dl>
  276.  
  277. By default, an ordered list will start counting from 1. If you want to start counting from a specified number, you can use the start attribute:
  278.  
  279.  
  280. Block-level Elements
  281. A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can).
  282.  
  283. The <div> element is a block-level element.
  284. <div>Hello</div>
  285. <div>World</div>
  286.  
  287.  
  288. The <div> element is often used as a container for other HTML elements.
  289. The <div> element has no required attributes, but style, class and id are common.
  290. When used together with CSS, the <div> element can be used to style blocks of content:
  291.  
  292. The <span> element is often used as a container for some text.
  293. The <span> element has no required attributes, but style, class and id are common.
  294. When used together with CSS, the <span> element can be used to style parts of the text:
  295.  
  296.  
  297.  
  298. The class attribute specifies one or more class names for an HTML element.
  299. The class name can be used by CSS and JavaScript to perform certain tasks for elements with the specified class name.
  300. In CSS, to select elements with a specific class, write a period (.) character, followed by the name of the class:
  301.  
  302. JavaScript can access elements with a specified class name by using the getElementsByClassName() method:
  303.  
  304.  
  305. The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document).
  306. The id value can be used by CSS and JavaScript to perform certain tasks for a unique element with the specified id value.
  307. In CSS, to select an element with a specific id, write a hash (#) character, followed by the id of the element:
  308.  
  309.  
  310.  
  311. An HTML element can only have one unique id that belongs to that single element, while a class name can be used by multiple elements:
  312.  
  313.  
  314. An iframe is used to display a web page within a web page.
  315. An HTML iframe is defined with the <iframe> tag:
  316. <iframe src="URL"></iframe>
  317.  
  318. The <script> tag is used to define a client-side script (JavaScript).
  319.  
  320. The <script> element either contains scripting statements, or it points to an external script file through the src attribute.
  321.  
  322. The <noscript> tag is used to provide an alternate content for users that have disabled scripts in their browser or have a browser that doesn't support client-side scripts:
  323.  
  324. The <meta> element is used to specify which character set is used, page description, keywords, author, and other metadata.
  325.  
  326.  
  327. HTML5 introduced a method to let web designers take control over the viewport, through the <meta> tag.
  328.  
  329. The viewport is the user's visible area of a web page. It varies with the device, and will be smaller on a mobile phone than on a computer screen.
  330.  
  331. You should include the following <meta> viewport element in all your web pages:
  332.  
  333. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  334.  
  335. A <meta> viewport element gives the browser instructions on how to control the page's dimensions and scaling.
  336.  
  337. The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).
  338.  
  339. The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.
  340.  
  341.  
  342. The <base> element specifies the base URL and base target for all relative URLs in a page:
  343.  
  344.  
  345. Websites often display content in multiple columns (like a magazine or newspaper).
  346.  
  347. HTML5 offers new semantic elements that define the different parts of a web page:
  348.  
  349. <header> - Defines a header for a document or a section
  350. <nav> - Defines a container for navigation links
  351. <section> - Defines a section in a document
  352. <article> - Defines an independent self-contained article
  353. <aside> - Defines content aside from the content (like a sidebar)
  354. <footer> - Defines a footer for a document or a section
  355. <details> - Defines additional details
  356. <summary> - Defines a heading for the <details> element
  357.  
  358.  
  359. There are four different ways to create multicolumn layouts. Each way has its pros and cons:
  360.  
  361. HTML tables
  362. CSS float property
  363. CSS framework
  364. CSS flexbox
  365.  
  366.  
  367. What is Responsive Web Design?
  368. Responsive Web Design makes your web page look good on all devices (desktops, tablets, and phones).
  369.  
  370. Responsive Web Design is about using HTML and CSS to resize, hide, shrink, enlarge, or move the content to make it look good on any screen.
  371.  
  372. Responsive Images
  373. Responsive images are images that scale nicely to fit any browser size.
  374.  
  375. Using the width Property
  376. If the CSS width property is set to 100%, the image will be responsive and scale up and down:
  377.  
  378. <img src="img_girl.jpg" style="width:100%;">
  379.  
  380.  
  381. Using the max-width Property
  382. If the max-width property is set to 100%, the image will scale down if it has to, but never scale up to be larger than its original size.
  383.  
  384. The text size can be set with a "vw" unit, which means the "viewport width".
  385. <h1 style="font-size:10vw">Hello World</h1>
  386.  
  387. In addition to resize text and images, it is also common to use media queries in responsive web pages.
  388.  
  389. With media queries you can define completely different styles for different browser sizes.
  390.  
  391.  
  392. HTML <kbd> For Keyboard Input
  393. The HTML <kbd> element represents user input, like keyboard input or voice commands.
  394.  
  395. Text surrounded by <kbd> tags is typically displayed in the browser's default monospace font.
  396.  
  397. The HTML <samp> element represents output from a program or computing system.
  398.  
  399. Text surrounded by <samp> tags is typically displayed in the browser's default monospace font.
  400.  
  401.  
  402. The HTML <code> element defines a fragment of computer code.
  403.  
  404. The HTML <var> element defines a variable.
  405.  
  406.  
  407. The HTML <form> element defines a form that is used to collect user input:
  408. <form>
  409. .
  410. form elements
  411. .
  412. </form>
  413.  
  414. The <input> element is the most important form element.
  415. The <input> element can be displayed in several ways, depending on the type attribute.
  416. Type Description
  417. <input type="text"> Defines a one-line text input field
  418. <input type="radio"> Defines a radio button (for selecting one of many choices)
  419. <input type="submit"> Defines a submit button (for submitting the form)
  420.  
  421.  
  422. <input type="text"> defines a one-line input field for text input:
  423. <form>
  424. First name:<br>
  425. <input type="text" name="firstname"><br>
  426. Last name:<br>
  427. <input type="text" name="lastname">
  428. </form>
  429.  
  430.  
  431. <input type="radio"> defines a radio button.
  432. Radio buttons let a user select ONE of a limited number of choices:
  433. <form>
  434. <input type="radio" name="gender" value="male" checked> Male<br>
  435. <input type="radio" name="gender" value="female"> Female<br>
  436. <input type="radio" name="gender" value="other"> Other
  437. </form>
  438.  
  439.  
  440. <input type="submit"> defines a button for submitting the form data to a form-handler.
  441. The form-handler is typically a server page with a script for processing input data.
  442. The form-handler is specified in the form's action attribute:
  443. <input type="submit" value="Submit">
  444.  
  445.  
  446. The action attribute defines the action to be performed when the form is submitted.
  447. Normally, the form data is sent to a web page on the server when the user clicks on the submit button.
  448.  
  449. The target attribute specifies if the submitted result will open in a new browser tab, a frame, or in the current window.
  450. The default value is "_self" which means the form will be submitted in the current window.
  451.  
  452. The method attribute specifies the HTTP method (GET or POST) to be used when submitting the form data:
  453. <form action="/action_page.php" method="get">
  454. or
  455. <form action="/action_page.php" method="post">
  456.  
  457. The default method when submitting form data is GET.
  458. However, when GET is used, the submitted form data will be visible in the page address field:
  459. /action_page.php?firstname=Mickey&lastname=Mouse
  460.  
  461.  
  462. Always use POST if the form data contains sensitive or personal information. The POST method does not display the submitted form data in the page address field.
  463.  
  464. Each input field must have a name attribute to be submitted.
  465. If the name attribute is omitted, the data of that input field will not be sent at all.
  466.  
  467.  
  468. The <fieldset> element is used to group related data in a form.
  469. The <legend> element defines a caption for the fieldset> element.
  470.  
  471. The <select> element defines a drop-down list:
  472. <select name="cars">
  473. <option value="volvo">Volvo</option>
  474. <option value="saab">Saab</option>
  475. <option value="fiat">Fiat</option>
  476. <option value="audi">Audi</option>
  477. </select>
  478.  
  479. The <option> elements defines an option that can be selected.
  480. By default, the first item in the drop-down list is selected.
  481. To define a pre-selected option, add the selected attribute to the option.
  482. Use the size attribute to specify the number of visible values.
  483. Use the multiple attribute to allow the user to select more than one value.
  484.  
  485.  
  486. The <textarea> element defines a multi-line input field (a text area):
  487. <textarea name="message" rows="10" cols="30">
  488. The cat was playing in the garden.
  489. </textarea>
  490.  
  491. The rows attribute specifies the visible number of lines in a text area.
  492. The cols attribute specifies the visible width of a text area.
  493.  
  494.  
  495. The <button> element defines a clickable button:
  496. <button type="button" onclick="alert('Hello World!')">Click Me!</button>
  497.  
  498.  
  499. HTML5 added the following form elements:
  500.  
  501. <datalist>
  502. <output>
  503.  
  504. The <datalist> element specifies a list of pre-defined options for an <input> element.
  505. Users will see a drop-down list of the pre-defined options as they input data.
  506. The list attribute of the <input> element, must refer to the id attribute of the <datalist> element.
  507.  
  508.  
  509. The <output> element represents the result of a calculation (like one performed by a script).
  510.  
  511.  
  512. <input type="password"> defines a password field.
  513.  
  514. <input type="reset"> defines a reset button that will reset all form values to their default values.
  515.  
  516. <input type="checkbox"> defines a checkbox.
  517. Checkboxes let a user select ZERO or MORE options of a limited number of choices.
  518. <form>
  519. <input type="checkbox" name="vehicle1" value="Bike"> I have a bike<br>
  520. <input type="checkbox" name="vehicle2" value="Car"> I have a car
  521. </form>
  522.  
  523. HTML5 added several new input types:
  524.  
  525. color The <input type="color"> is used for input fields that should contain a color.
  526. date The <input type="date"> is used for input fields that should contain a date.
  527. datetime-local The <input type="datetime-local"> specifies a date and time input field, with no time zone.
  528. email The <input type="email"> is used for input fields that should contain an e-mail address.
  529. month The <input type="month"> allows the user to select a month and year.
  530. number The <input type="number"> defines a numeric input field.
  531. range The <input type="range"> defines a control for entering a number whose exact value is not important (like a slider control). Default range is 0 to 100. However, you can set restrictions on what numbers are accepted with the min, max, and step attributes.
  532. search The <input type="search"> is used for search fields (a search field behaves like a regular text field).
  533. tel The <input type="tel"> is used for input fields that should contain a telephone number.
  534. time The <input type="time"> allows the user to select a time (no time zone).
  535. url The <input type="url"> is used for input fields that should contain a URL address.
  536. week The <input type="week"> allows the user to select a week and year.
  537.  
  538.  
  539. The value attribute specifies the initial value for an input field.
  540.  
  541. The readonly attribute specifies that the input field is read only (cannot be changed).
  542.  
  543. The disabled attribute specifies that the input field is disabled.
  544.  
  545. The size attribute specifies the size (in characters) for the input field.
  546.  
  547. The maxlength attribute specifies the maximum allowed length for the input field.
  548.  
  549. HTML5 added the following attributes for <input>:
  550.  
  551. autocomplete
  552. autofocus
  553. form
  554. formaction
  555. formenctype
  556. formmethod
  557. formnovalidate
  558. formtarget
  559. height and width
  560. list
  561. min and max
  562. multiple
  563. pattern (regexp)
  564. placeholder
  565. required
  566. step
  567.  
  568.  
  569. The autocomplete attribute specifies whether a form or input field should have autocomplete on or off.
  570. When autocomplete is on, the browser automatically completes the input values based on values that the user has entered before.
  571. Tip: It is possible to have autocomplete "on" for the form, and "off" for specific input fields, or vice versa.
  572. The autocomplete attribute works with <form> and the following <input> types: text, search, url, tel, email, password, datepickers, range, and color.
  573.  
  574.  
  575. The novalidate attribute is a <form> attribute.
  576. When present, novalidate specifies that the form data should not be validated when submitted.
  577.  
  578. The autofocus attribute specifies that the input field should automatically get focus when the page loads.
  579.  
  580. The form attribute specifies one or more forms an <input> element belongs to.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement