diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
commit | da78a9e329e272dedb2400b79a3bdeebff387d47 (patch) | |
tree | e6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ms/learn | |
parent | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff) | |
download | translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2 translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip |
initial commit
Diffstat (limited to 'files/ms/learn')
-rw-r--r-- | files/ms/learn/accessibility/index.html | 89 | ||||
-rw-r--r-- | files/ms/learn/html/forms/index.html | 340 | ||||
-rw-r--r-- | files/ms/learn/html/howto/add_responsive_image_to_a_webpage/index.html | 170 | ||||
-rw-r--r-- | files/ms/learn/html/howto/index.html | 153 | ||||
-rw-r--r-- | files/ms/learn/html/index.html | 48 | ||||
-rw-r--r-- | files/ms/learn/index.html | 94 | ||||
-rw-r--r-- | files/ms/learn/memulakan_pembelajaran_web/berurusan_dengan_fail/index.html | 103 | ||||
-rw-r--r-- | files/ms/learn/memulakan_pembelajaran_web/index.html | 57 | ||||
-rw-r--r-- | files/ms/learn/memulakan_pembelajaran_web/memasang_perisian_asas/index.html | 58 | ||||
-rw-r--r-- | files/ms/learn/server-side/express_nodejs/forms/index.html | 276 | ||||
-rw-r--r-- | files/ms/learn/server-side/express_nodejs/index.html | 77 | ||||
-rw-r--r-- | files/ms/learn/server-side/index.html | 59 | ||||
-rw-r--r-- | files/ms/learn/soalan_lazim/index.html | 119 |
13 files changed, 1643 insertions, 0 deletions
diff --git a/files/ms/learn/accessibility/index.html b/files/ms/learn/accessibility/index.html new file mode 100644 index 0000000000..22617a9e99 --- /dev/null +++ b/files/ms/learn/accessibility/index.html @@ -0,0 +1,89 @@ +--- +title: Accessibility +slug: Learn/Accessibility +tags: + - ARIA + - Accessibility + - Articles + - Beginner + - CSS + - CodingScripting + - HTML + - JavaScript + - Landing + - Learn + - Module + - NeedsTranslation + - TopicStub +translation_of: Learn/Accessibility +--- +<div>{{LearnSidebar}}</div> + +<p class="summary">Learning some HTML, CSS, and JavaScript is useful if you want to become a web developer. Beyond mechanical use, it's important to learn how to use these technologies <strong>responsibly</strong> so that all readers might use your creations on the web. To help you achieve this, this module will cover general best practices (which are demonstrated throughout the <a href="/en-US/docs/Learn/HTML">HTML</a>, <a href="/en-US/docs/Learn/CSS">CSS</a>, and <a href="/en-US/docs/Learn/JavaScript">JavaScript</a> topics), <a href="/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing">cross browser testing</a>, and some tips on enforcing accessibility from the start. We'll cover accessibility in special detail.</p> + +<h2 id="Overview">Overview</h2> + +<p>When someone describes a site as "accessible," they mean that any user can use all its features and content, regardless of how the user accesses the web — even and especially users with physical or mental impairments.</p> + +<ul> + <li>Sites should be accessible to keyboard, mouse, and touch screen users, and any other way users access the web, including screen readers and voice assistants like Alexa and Google Home.</li> + <li>Applications should be understandable and usable by people regardless of auditory, visual, physical, or cognitive abilities.</li> + <li>Sites should also not cause harm: web features like motion can cause migraines or epileptic seizures.</li> +</ul> + +<p><strong>By default, HTML is accessible, if used correctly.</strong> Web accessibility involves ensuring that content remains accessible, regardless of who and how the web is accessed.</p> + +<p>The Firefox Accessibility Inspector is a very useful tool for checking out accessibility issues on web pages. The following video provides a nice introduction to it:</p> + +<p>{{EmbedYouTube("7mqqgIxX_NU")}}</p> + +<div class="in-page-callout webdev"> +<h3 id="Looking_to_become_a_front-end_web_developer">Looking to become a front-end web developer?</h3> + +<p>We have put together a course that includes all the essential information you need to work towards your goal.</p> + +<p><a class="cta primary" href="/docs/Learn/Front-end_web_developer">Get started</a></p> +</div> + +<h2 id="Prerequisites">Prerequisites</h2> + +<p>To get the most out of this module, it would be a good idea to either work through at least the first two modules of the <a href="/en-US/docs/Learn/HTML">HTML</a>, <a href="/en-US/docs/Learn/CSS">CSS</a>, and <a href="/en-US/docs/Learn/JavaScript">JavaScript</a> topics, or perhaps even better, work through the relevant parts of the accessibility module as you work through the related technology topics.</p> + +<div class="note"> +<p><strong>Note</strong>: If you are working on a computer/tablet/other devices where you don't have the ability to create your own files, you can try out most of the code examples in an online coding program such as <a href="http://jsbin.com/">JSBin</a> or <a href="https://glitch.com/">Glitch</a>.</p> +</div> + +<h2 id="Guides">Guides</h2> + +<dl> + <dt><a href="/en-US/docs/Learn/Accessibility/What_is_accessibility">What is accessibility?</a></dt> + <dd>This article starts off the module with a good look at what accessibility is — this includes what groups of people we need to consider and why, what tools different people use to interact with the web, and how we can make accessibility part of our web development workflow.</dd> + <dt><a href="/en-US/docs/Learn/Accessibility/HTML">HTML: A good basis for accessibility</a></dt> + <dd>A great deal of web content can be made accessible just by making sure the correct HTML elements are always used for the correct purpose. This article looks in detail at how HTML can be used to ensure maximum accessibility.</dd> + <dt><a href="/en-US/docs/Learn/Accessibility/CSS_and_JavaScript">CSS and JavaScript accessibility best practices</a></dt> + <dd>CSS and JavaScript, when used properly, also have the potential to allow for accessible web experiences, but if misused they can significantly harm accessibility. This article outlines some CSS and JavaScript best practices that should be considered to ensure that even complex content is as accessible as possible.</dd> + <dt><a href="/en-US/docs/Learn/Accessibility/WAI-ARIA_basics">WAI-ARIA basics</a></dt> + <dd>Following on from the previous article, sometimes making complex UI controls that involve unsemantic HTML and dynamic JavaScript-updated content can be difficult. WAI-ARIA is a technology that can help with such problems by adding in further semantics that browsers and assistive technologies can recognize and use to let users know what is going on. Here we'll show how to use it at a basic level to improve accessibility.</dd> + <dt><a href="/en-US/docs/Learn/Accessibility/Multimedia">Accessible multimedia</a></dt> + <dd>Another category of content that can create accessibility problems is multimedia — video, audio, and image content need to be given proper textual alternatives, so they can be understood by assistive technologies and their users. This article shows how.</dd> + <dt><a href="/en-US/docs/Learn/Accessibility/Mobile">Mobile accessibility</a></dt> + <dd>With web access on mobile devices being so popular, and popular platforms such as iOS and Android having fully-fledged accessibility tools, it is important to consider the accessibility of your web content on these platforms. This article looks at mobile-specific accessibility considerations.</dd> +</dl> + +<h2 id="Assessments">Assessments</h2> + +<dl> + <dt><a href="/en-US/docs/Learn/Accessibility/Accessibility_troubleshooting">Accessibility troubleshooting</a></dt> + <dd> + <p>In the assessment for this module, we present to you a simple site with several accessibility issues that you need to diagnose and fix.</p> + </dd> +</dl> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="https://egghead.io/courses/start-building-accessible-web-applications-today">Start Building Accessible Web Applications Today</a> — an excellent series of video tutorials by Marcy Sutton.</li> + <li><a href="https://dequeuniversity.com/resources/">Deque University resources</a> — includes code examples, screen reader references, and other useful resources.</li> + <li><a href="http://webaim.org/resources/">WebAIM resources</a> — includes guides, checklists, tools, and more.</li> + <li><a href="https://www.w3.org/WAI/ER/tools/">Web Accessibility Evaluation Tools List</a> — includes a list of web accessibility evaluation tools.</li> +</ul> diff --git a/files/ms/learn/html/forms/index.html b/files/ms/learn/html/forms/index.html new file mode 100644 index 0000000000..10e84875de --- /dev/null +++ b/files/ms/learn/html/forms/index.html @@ -0,0 +1,340 @@ +--- +title: Panduan Borang HTML +slug: Learn/HTML/Forms +translation_of: Learn/Forms +--- +<p>Welcome to the Guide to HTML Forms. This guide is a series of articles that will help you master HTML Forms. HTML Forms are a very powerful tool to interact with a user; however, due to historical and technical reasons, it's not always obvious how you use them to their full potential. In this guide, we'll cover all aspects of HTML Forms, from structure to styling, from data handling to custom widgets. You'll learn to enjoy the great power they offer!</p> +<h2 id="Articles">Articles</h2> +<ol> + <li><a href="/en-US/docs/HTML/Forms/My_first_HTML_form" title="/en-US/docs/HTML/Forms/My_first_HTML_form">My first HTML form</a></li> + <li><a href="/en-US/docs/HTML/Forms/How_to_structure_an_HTML_form" title="/en-US/docs/HTML/Forms/How_to_structure_an_HTML_form"><span>How to structure an HTML form</span></a></li> + <li><a href="/en-US/docs/HTML/Forms/The_native_form_widgets" title="/en-US/docs/HTML/Forms/The_native_form_widgets"><span>The native form widgets</span></a></li> + <li>CSS with HTML forms + <ol> + <li><a href="/en-US/docs/HTML/Forms/Styling_HTML_forms" title="/en-US/docs/HTML/Forms/Styling_HTML_forms"><span>Styling HTML forms</span></a></li> + <li><a href="/en-US/docs/Advanced_styling_for_HTML_forms" title="/en-US/docs/Advanced_styling_for_HTML_forms">Advanced styling for HTML forms</a></li> + <li><a href="/en-US/docs/Property_compatibility_table_for_form_widgets" title="/en-US/docs/Property_compatibility_table_for_form_widgets">Property compatibility table for form widgets</a></li> + </ol> + </li> + <li><a href="/en-US/docs/HTML/Forms/Sending_and_retrieving_form_data" title="/en-US/docs/HTML/Forms/Sending_and_retrieving_form_data"><span>Sending and retrieving form data</span></a></li> + <li><a href="/en-US/docs/HTML/Forms/Data_form_validation" title="/en-US/docs/HTML/Forms/Data_form_validation">Data form validation</a></li> + <li><a href="/en-US/docs/HTML/Forms/How_to_build_custom_form_widgets" title="/en-US/docs/HTML/Forms/How_to_build_custom_form_widgets">How to <span>build custom form widgets</span></a></li> + <li><a href="/en-US/docs/HTML/Forms/Sending_forms_through_JavaScript" title="/en-US/docs/HTML/Forms/Sending_forms_through_JavaScript">Sending forms through JavaScript</a> + <ol> + <li><a href="/en-US/docs/DOM/XMLHttpRequest/FormData/Using_FormData_Objects" title="/en-US/docs/DOM/XMLHttpRequest/FormData/Using_FormData_Objects">Using the FormData object</a></li> + </ol> + </li> + <li><a href="/en-US/docs/HTML/Forms/HTML_forms_in_legacy_browsers" title="/en-US/docs/HTML/Forms/HTML_forms_in_legacy_browsers">HTML forms in legacy browsers</a></li> +</ol> +<h2 id="HTML_Documentation">HTML Documentation</h2> +<h3 id="HTML_Elements">HTML Elements</h3> +<table> + <thead> + <tr> + <th scope="col">Element</th> + <th scope="col">Related DOM interface</th> + <th scope="col">Description</th> + </tr> + </thead> + <tbody> + <tr> + <td style="vertical-align: top;">{{HTMLElement("button")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLButtonElement")}}</td> + <td style="vertical-align: top;">The <code>button</code> element represents a clickable button.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("datalist")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLDataListElement")}}</td> + <td style="vertical-align: top;">The <span style="font-family: Courier New;">datalist</span> element contains a set of {{ HTMLElement("option") }} elements that represent the possible options for the value of other forms elements.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("fieldset")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLFieldSetElement")}}</td> + <td style="vertical-align: top;">The <span style="font-family: Courier New;">fieldset</span> is used to group several form elements within a form.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("form")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLFormElement")}}</td> + <td style="vertical-align: top;">The <code>form</code> element represents a section of document that contains interactive element that enable a user to submit information to a web server.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("input")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLInputElement")}}</td> + <td style="vertical-align: top;">The <code>input</code> element is used to create interactive controls for forms.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("keygen")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLKeygenElement")}}</td> + <td style="vertical-align: top;">The <code>keygen</code> element exists to facilitate generation of key material, and submission of the public key as part of an HTML form</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("label")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLLabelElement")}}</td> + <td style="vertical-align: top;">The <code>label</code> element represents a caption for an item in a user interface</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("legend")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLLegendElement")}}</td> + <td style="vertical-align: top;">The <code>legend</code> element represents a caption for the content of its parent {{ HTMLElement("fieldset") }}.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("meter")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLMeterElement")}}</td> + <td style="vertical-align: top;">The <code>meter</code> element represents either a scalar value within a known range or a fractional value.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("optgroup")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLOptGroupElement")}}</td> + <td style="vertical-align: top;">the <code>optgroup</code> element creates a group of options within a {{ HTMLElement("select") }} element.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("option")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLOptionElement")}}</td> + <td style="vertical-align: top;">the HTML<em> </em><code>option<em> </em></code>element is used to create a control representing an item within a {{ HTMLElement("select") }}, an {{ HTMLElement("optgroup") }} or a {{ HTMLElement("datalist") }} element.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("output")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLOutputElement")}}</td> + <td style="vertical-align: top;">The <code>output</code> element represents the result of a calculation.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("progress")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLProgressElement")}}</td> + <td style="vertical-align: top;">The <code>progress</code> element is used to view the completion progress of a task.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("select")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLSelectElement")}}</td> + <td style="vertical-align: top;">The <code>select</code> element represents a control that presents a menu of options.</td> + </tr> + <tr> + <td style="vertical-align: top;">{{HTMLElement("textarea")}}</td> + <td style="vertical-align: top;">{{domxref("HTMLTextAreaElement")}}</td> + <td style="vertical-align: top;">The <code>textarea</code> element represents a multi-line plain-text editing control.</td> + </tr> + </tbody> +</table> +<div class="note"> + <p><strong>Note:</strong> All form elements, as all HTML elements, support the {{domxref("HTMLElement")}} DOM interface.</p> +</div> +<h3 id="HTML_Attributes">HTML Attributes</h3> +<table class="standard-table"> + <thead> + <tr> + <th>Attribute Name</th> + <th>Elements</th> + <th>Description</th> + </tr> + </thead> + <tbody> + <tr> + <td>accept</td> + <td>{{ HTMLElement("form") }}, {{ HTMLElement("input") }}</td> + <td>List of types the server accepts, typically a file type.</td> + </tr> + <tr> + <td style="white-space: nowrap;">accept-charset</td> + <td>{{ HTMLElement("form") }}</td> + <td>List of supported charsets.</td> + </tr> + <tr> + <td>action</td> + <td>{{ HTMLElement("form") }}</td> + <td>The URI of a program that processes the information submitted via the form.</td> + </tr> + <tr> + <td>autocomplete</td> + <td>{{ HTMLElement("form") }}, {{ HTMLElement("input") }}</td> + <td>Indicates whether controls in this form can by default have their values automatically completed by the browser.</td> + </tr> + <tr> + <td>autofocus</td> + <td>{{ HTMLElement("button") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}</td> + <td>The element should be automatically focused after the page loaded.</td> + </tr> + </tbody> + <tbody> + <tr> + <td>challenge</td> + <td>{{ HTMLElement("keygen") }}</td> + <td>A challenge string that is submitted along with the public key.</td> + </tr> + <tr> + <td>checked</td> + <td>{{ HTMLElement("input") }}</td> + <td>Indicates whether the element should be checked on page load.</td> + </tr> + <tr> + <td>cols</td> + <td>{{ HTMLElement("textarea") }}</td> + <td>Defines the number of columns in a textarea.</td> + </tr> + <tr> + <td>data</td> + <td>{{ HTMLElement("object") }}</td> + <td>Specifies the URL of the resource.</td> + </tr> + <tr> + <td>dirname</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}</td> + <td> </td> + </tr> + <tr> + <td>disabled</td> + <td>{{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("optgroup") }}, {{ HTMLElement("option") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}</td> + <td>Indicates whether the user can interact with the element.</td> + </tr> + <tr> + <td>enctype</td> + <td>{{ HTMLElement("form") }}</td> + <td>Defines the content type of the form date when the <code>method</code> is POST.</td> + </tr> + <tr> + <td>for</td> + <td>{{ HTMLElement("label") }}, {{ HTMLElement("output") }}</td> + <td>Describes elements which belongs to this one.</td> + </tr> + <tr> + <td>form</td> + <td>{{ HTMLElement("button") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("label") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("object") }}, {{ HTMLElement("output") }}, {{ HTMLElement("progress") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}</td> + <td>Indicates the form that is the owner of the element.</td> + </tr> + </tbody> + <tbody> + <tr> + <td>high</td> + <td>{{ HTMLElement("meter") }}</td> + <td>Indicates the lower bound of the upper range.</td> + </tr> + <tr> + <td>keytype</td> + <td>{{ HTMLElement("keygen") }}</td> + <td>Specifies the type of key generated.</td> + </tr> + <tr> + <td>list</td> + <td>{{ HTMLElement("input") }}</td> + <td>Identifies a list of pre-defined options to suggest to the user.</td> + </tr> + <tr> + <td>low</td> + <td>{{ HTMLElement("meter") }}</td> + <td>Indicates the upper bound of the lower range.</td> + </tr> + <tr> + <td>max</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}</td> + <td>Indicates the maximum value allowed.</td> + </tr> + <tr> + <td>maxlength</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}</td> + <td>Defines the maximum number of characters allowed in the element.</td> + </tr> + <tr> + <td>method</td> + <td>{{ HTMLElement("form") }}</td> + <td>Defines which HTTP method to use when submitting the form. Can be GET (default) or POST.</td> + </tr> + <tr> + <td>min</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("meter") }}</td> + <td>Indicates the minimum value allowed.</td> + </tr> + <tr> + <td>multiple</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("select") }}</td> + <td>Indicates whether multiple values can be entered in an input of the type <code>email</code> or <code>file</code>.</td> + </tr> + <tr> + <td>name</td> + <td>{{ HTMLElement("button") }}, {{ HTMLElement("form") }}, {{ HTMLElement("fieldset") }}, {{ HTMLElement("input") }}, {{ HTMLElement("keygen") }}, {{ HTMLElement("output") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}</td> + <td>Name of the element. For example used by the server to identify the fields in form submits.</td> + </tr> + <tr> + <td>novalidate</td> + <td>{{ HTMLElement("form") }}</td> + <td>This attribute indicates that the form shouldn't be validated when submitted.</td> + </tr> + <tr> + <td>optimum</td> + <td>{{ HTMLElement("meter") }}</td> + <td>Indicates the optimal numeric value.</td> + </tr> + <tr> + <td>pattern</td> + <td>{{ HTMLElement("input") }}</td> + <td>Defines a regular expression which the element's value will be validated against.</td> + </tr> + <tr> + <td>placeholder</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}</td> + <td>Provides a hint to the user of what can be entered in the field.</td> + </tr> + <tr> + <td>readonly</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("textarea") }}</td> + <td>Indicates whether the element can be edited.</td> + </tr> + <tr> + <td>required</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("select") }}, {{ HTMLElement("textarea") }}</td> + <td>Indicates whether this element is required to fill out or not.</td> + </tr> + <tr> + <td>rows</td> + <td>{{ HTMLElement("textarea") }}</td> + <td>Defines the number of rows in a textarea.</td> + </tr> + <tr> + <td>selected</td> + <td>{{ HTMLElement("option") }}</td> + <td>Defines a value which will be selected on page load.</td> + </tr> + <tr> + <td>size</td> + <td>{{ HTMLElement("input") }}, {{ HTMLElement("select") }}</td> + <td>Defines the width of the element (in pixels). If the element's <code>type</code> attribute is <code>text</code> or <code>password</code> then it's the number of characters.</td> + </tr> + <tr> + <td>src</td> + <td>{{ HTMLElement("input") }}</td> + <td>The URL of the embeddable content.</td> + </tr> + <tr> + <td>step</td> + <td>{{ HTMLElement("input") }}</td> + <td> </td> + </tr> + <tr> + <td>target</td> + <td>{{ HTMLElement("form") }}</td> + <td> </td> + </tr> + <tr> + <td>type</td> + <td>{{ HTMLElement("button") }}, {{ HTMLElement("input") }}</td> + <td>Defines the type of the element.</td> + </tr> + <tr> + <td>usemap</td> + <td>{{ HTMLElement("input") }}</td> + <td> </td> + </tr> + <tr> + <td>value</td> + <td>{{ HTMLElement("button") }}, {{ HTMLElement("option") }}, {{ HTMLElement("input") }}, {{ HTMLElement("meter") }}, {{ HTMLElement("progress") }}</td> + <td>Defines a default value which will be displayed in the element on page load.</td> + </tr> + <tr> + <td>wrap</td> + <td>{{ HTMLElement("textarea") }}</td> + <td>Indicates whether the text should be wrapped.</td> + </tr> + </tbody> +</table> +<h3 id="Normative_reference">Normative reference</h3> +<ul> + <li><a href="http://www.w3.org/TR/html5/forms.html" lang="en" rel="external" title="http://www.w3.org/TR/html5/forms.html">W3C HTML5 Specification (Forms)</a></li> + <li><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#forms" rel="external" title="http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#forms">WHATWG HTML Living Standard (Forms)</a></li> +</ul> diff --git a/files/ms/learn/html/howto/add_responsive_image_to_a_webpage/index.html b/files/ms/learn/html/howto/add_responsive_image_to_a_webpage/index.html new file mode 100644 index 0000000000..0589cda2d8 --- /dev/null +++ b/files/ms/learn/html/howto/add_responsive_image_to_a_webpage/index.html @@ -0,0 +1,170 @@ +--- +title: Add responsive images to a webpage +slug: Learn/HTML/Howto/Add_responsive_image_to_a_webpage +translation_of: Learn/HTML/Multimedia_and_embedding/Responsive_images +--- +<div class="summary"> +<p><span class="seoSummary">Learn about HTML features you can use to adapt your site's images to various screen sizes and display resolutions.</span></p> +</div> + +<table class="learn-box nostripe standard-table"> + <tbody> + <tr> + <th scope="row">Prerequisites:</th> + <td>You should already know how to <a href="/en-US/Learn/HTML/Write_a_simple_page_in_HTML">create a basic HTML document</a> and how to <a href="https://developer.mozilla.org/en-US/Learn/HTML/Howto/Add_images_to_a_webpage">add static images to a webpage.</a></td> + </tr> + <tr> + <th scope="row">Objective:</th> + <td>Learn how to feed multiple source files to your {{htmlelement("img")}} element, so the browser can pull the right image for the occasion.</td> + </tr> + </tbody> +</table> + +<div class="note"> +<p><strong>Note:</strong> Vector images are the ultimate responsive images because the files are small while the images are scalable to any size without loss of definition. <a href="https://developer.mozilla.org/en-US/Learn/HTML/Howto/Add_vector_image_to_a_webpage">Use vector images</a> whenever you can; they're even more effective than the techniques described here. This article demonstrates how to use multiple versions of a bitmap image, in different sizes, to provide the best possible output given the current screen size and resolution.</p> + +<p>Note also that while this article discusses how to implement responsive images in HTML, <a href="http://blog.cloudfour.com/responsive-images-101-part-8-css-images/">sometimes it makes more sense to use CSS</a>.</p> +</div> + +<h2 id="Why_responsive_images">Why responsive images?</h2> + +<p>Here's the problem we're solving:</p> + +<p>On a webpage, you have a box that must be filled by an image. More precisely, the box must be filled by pixels, so many wide by so many tall. Just how many pixels wide and tall depends on your visitor's device.</p> + +<p>You also have an image file, a set number of pixels wide and a set number of pixels tall. The image naturally should display in a box the same number of pixels wide and tall as the image. If the box is significantly too big, the image doesn't have enough pixels and it's going to look grainy. If the box is significantly too small, you're wasting bandwidth and slowing down your page by loading a larger image than you need.</p> + +<p><em>Responsive images </em>solves this problem by letting you offer the browser several image files, all showing the same thing but containing different numbers of pixels. That way the browser can load an image that will look sharp enough but won't needlessly slow down the page.</p> + +<h2 id="So_how_do_you_do_it">So how do you do it?</h2> + +<p>In this section, we'll solve what is, by far, the most common problem: displaying identical image content, just larger or smaller depending on the device. In the next section, we'll look at some less common scenarios.</p> + +<p>Remember the {{htmlelement("img")}} element? It lets you point the browser to a single source file:</p> + +<pre class="brush: html"><img src="chalet.jpg" alt="Quaint wooden cottage in the Alps"></pre> + +<p>We can use two new attributes, {{htmlattrxref("srcset", "img")}} and {{htmlattrxref("sizes", "img")}} <code>sizes</code> (<strong>in addition to</strong> {{htmlattrxref("alt", "img")}} and {{htmlattrxref("src", "img")}}), to provide several additional source images and enough information to help the browser pick the right one. It looks like this when you're done:</p> + +<pre class="brush: html"><img + src="chalet.jpg" + alt="Quaint wooden cottage in the Alps" + srcset=" + chalet-256.jpg 256w, + chalet-512.jpg 512w, + chalet-1024.jpg 1024w" + sizes=" + (max-width: 500px) 100vw, + (max-width: 900px) 40vw, + 400px"> +</pre> + +<p><code>srcset</code> and <code>sizes</code> each contain comma-separated lists.</p> + +<p><strong>For <code>srcset</code>: </strong>Between the commas, write</p> + +<ol> + <li>an <strong>image filename</strong> (<code>chalet-256.jpg</code>)</li> + <li>a space</li> + <li>the image's <strong>inherent width in pixels</strong> (<code>256w</code>)</li> +</ol> + +<p><strong>For <code>sizes</code>: </strong>Between the commas, write</p> + +<ol> + <li>a <strong>media condition</strong> (<code>(max-width:500px)</code>)</li> + <li>a space</li> + <li>the <strong>width of the slot</strong> the image will fill when the media condition is true (<code>100vw</code>)</li> +</ol> + +<div class="note"> +<ul> + <li>For the slot width, you may provide an absolute length (<code>px</code>, <code>em</code>) or a relative length (<code>vw</code>, that is, percent of viewport width). You may also provide a combination using {{cssxref("calc")}}.</li> + <li>The last slot width is the default (for when no media condition is true). Therefore, the last slot width has <strong>no</strong> media condition.</li> + <li><code>max-width</code> simply means, "if the user's screen is no wider than X pixels".</li> + <li>The browser ignores everything after the first matching condition. Pay attention to the order of the media conditions.</li> +</ul> +</div> + +<div class="note"> +<p><strong>Why can't the browser just look at the CSS to find out the width of the image slot? </strong></p> + +<p>Because the browser's preloader starts downloading images before the main parser has a chance to interpret CSS and JavaScript. You want that, because images are heavy and circumventing the preloader may add another 20% on to your page load time.</p> +</div> + +<h2 id="Advanced_scenarios">Advanced scenarios</h2> + +<h3 id="Images_at_different_resolutions_but_one_real-world_size">Images at different resolutions but one real-world size</h3> + +<p>If you're supporting multiple display densities, but everyone sees your image at the same real-world size, you should use <code>srcset</code> with x-descriptors and without <code>sizes</code>:</p> + +<pre class="brush: html"><img + src="chalet.jpg" + alt="Quaint wooden cottage in the Alps" + srcset="chalet.jpg, + chalet-1-5x.jpg 1.5x, + chalet-2x.jpg 2x, + chalet-3x.jpg 3x"> +</pre> + +<div class="note"> +<ul> + <li> + <p>Note that <code>1x</code> is implied.</p> + </li> + <li> + <p><code>x</code> means, "this many device pixels for one CSS pixel"</p> + </li> +</ul> +</div> + +<h3 id="Art_direction">Art direction</h3> + +<p><strong>Art direction</strong> means cropping an image either 1) to make the main subject easier to see when the image is small or 2) to make a landscape image suitable for a portrait slot (and vice versa). (However, it must be the same image content in all cases. To, say, show phone users a jet and desktop users a ladybug is a misuse of the responsive image mechanism.)<br> + Art direction is a more complex problem, and needs a more complex solution: the {{htmlelement("picture")}} element. <code><picture></code> is a wrapper containing several {{htmlelement("source")}} elements, followed by the all-important {{htmlelement("img")}} element:</p> + +<pre class="brush: html"><picture> + <source + media="(min-width: 1000px)" + srcset="chalet-desktop.jpg"> + <source + media="(min-width: 700px)" + srcset="chalet-tablet.jpg"> + <img src="chalet-phone.jpg" alt="Quaint wooden cottage in the Alps"> +</picture> +</pre> + +<ul> + <li>Just like <code><img></code>, <code><source></code> can take <code>srcset</code> and <code>sizes</code>. In a responsive images scenario, do not use <code><source></code> and <code>src</code> together.</li> + <li><code><source></code> may also take a <code>media</code> attribute containing a CSS <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries">media query</a>. Use <code>media</code> only in an art direction scenario, because it leaves the browser no choice of which image to use. When you do use <code>media</code>, don't offer media conditions within <code>sizes</code>.</li> + <li><strong>In all cases, you must provide an <code><img></code> element, with <code>src</code> and <code>alt</code>, right before <code></picture></code>, otherwise no images will appear.</strong></li> +</ul> + +<h3 id="Use_modern_image_formats_boldly">Use modern image formats boldly</h3> + +<p>There are several exciting new image formats (think WebP and JPEG-2000) that can maintain a low file size and high quality at the same time. However, browser support is spotty.</p> + +<p><code><picture></code> lets us continue catering to older browsers. Supply MIME types inside <code>type</code> attributes so the browser can immediately reject unsupported file types:</p> + +<pre class="brush: html"><picture> + <source type="image/svg+xml" srcset="pyramid.svg"> + <source type="image/webp" srcset="pyramid.webp"> + <img src="pyramid.png" alt="regular pyramid built from four equilateral triangles"> +</picture> +</pre> + +<ul> + <li>Do <em>not </em>use the <code>media</code> attribute, unless you also need art direction.</li> + <li>In a <code><source></code> element, you can only refer to images of the type declared in <code>type</code>.</li> + <li>As before, you're welcome to use comma-separated lists with <code>srcset</code> and <code>sizes</code>, as needed.</li> +</ul> + +<h2 id="Learn_more">Learn more</h2> + +<ul> + <li><a href="http://blog.cloudfour.com/responsive-images-101-definitions">Jason Grigsby's excellent introduction to responsive images</a></li> + <li>{{htmlelement("img")}}</li> + <li>{{htmlelement("picture")}}</li> + <li>{{htmlelement("source")}}</li> + <li><a href="http://responsiveimages.org/">Responsive Images Community Group</a></li> +</ul> diff --git a/files/ms/learn/html/howto/index.html b/files/ms/learn/html/howto/index.html new file mode 100644 index 0000000000..7ce5cf622f --- /dev/null +++ b/files/ms/learn/html/howto/index.html @@ -0,0 +1,153 @@ +--- +title: Learn HTML to solve problems +slug: Learn/HTML/Howto +tags: + - CodingScripting + - HTML + - NeedsTranslation + - TopicStub +translation_of: Learn/HTML/Howto +--- +<p>Once you've covered <a href="/en-US/Learn/Getting_started_with_the_web/HTML_basics">the basics</a>, there isn't one right path to learn {{Glossary("HTML")}}. You can pick up whatever you like at your own pace. HTML is simply a set of {{glossary("tag","tags")}} you can use to set up your document structure and add extra functionality to your document. The following articles explain thoroughly, with full working examples, how to use HTML for the most common, frequent Web development tasks. If you need a quick explanation of a tag, please head over to our <a href="/en-US/docs/Web/HTML/Reference">HTML reference</a>.</p> + +<h2 id="Common_use_cases">Common use cases</h2> + +<p>HTML covers a lot of very common use cases in Web design. It's highly likely you'll come across these scenarios:</p> + +<div class="column-container"> +<div class="column-half"> +<h3 id="Basic_structure">Basic structure</h3> + +<p>The most basic application of HTML is document structure. If you're new to HTML you should start with this.</p> + +<ul> + <li><a href="/en-US/Learn/HTML/Howto/Create_a_basic_HTML_document">How to create a basic HTML document</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Divide_a_webpage_into_logical_sections">How to divide a webpage into logical sections</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Set_up_a_proper_title_hierarchy">How to set up a proper title hierarchy</a></li> +</ul> + +<h3 id="Basic_text-level_semantics">Basic text-level semantics</h3> + +<p>HTML specializes in providing semantic information for a document, so HTML answers many questions you might have about how to get your message across best in your document.</p> + +<ul> + <li><a href="/en-US/Learn/HTML/Howto/Create_list_of_items_with_HTML">How to create list of items with HTML</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Emphasize_content_or_indicate_that_text_is_important">How to stress or emphasize content</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Emphasize_content_or_indicate_that_text_is_important">How to indicate that text is important</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Display_computer_code_with_HTML">How to display computer code with HTML</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Indicate_exponential_notation_with_HTML">How to indicate exponential notation with HTML</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Provide_contact_information_within_a_webpage">How to provide contact information within a webpage</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Annotate_images_and_graphics">How to annotate images and graphics</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Mark_abbreviations_and_make_them_understandable">How to mark abbreviations and make them understandable</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Add_citations_to_webpages">How to add citations to webpages</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Define_terms_with_HTML">How to define terms with HTML</a></li> +</ul> +</div> + +<div class="column-half"> +<h3 id="Hyperlinks">Hyperlinks</h3> + +<p>One of the main reasons for HTML is make navigation easy with {{Glossary("hyperlink", "hyperlinks")}}, which can be used in many different ways:</p> + +<ul> + <li><a href="/en-US/Learn/HTML/Howto/Create_a_hyperlink">How to create a hyperlink</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Create_list_of_items_with_HTML">How to create a table of contents with HTML</a></li> +</ul> + +<h3 id="Images_multimedia">Images & multimedia</h3> + +<ul> + <li><a href="/en-US/Learn/HTML/Howto/Add_images_to_a_webpage">How to add images to a webpage</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Add_audio_or_video_content_to_a_webpage">How to add video content to a webpage</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Add_audio_or_video_content_to_a_webpage">How to add audio content to a webpage</a></li> +</ul> + +<h3 id="Scripting_styling">Scripting & styling</h3> + +<p>HTML only sets up document structure. To solve presentation issues, use {{glossary("CSS")}}, or use scripting to make your page interactive.</p> + +<ul> + <li><a href="/en-US/Learn/HTML/Howto/Use_CSS_within_a_webpage">How to use CSS within a webpage</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Use_JavaScript_within_a_webpage">How to use JavaScript within a webpage</a></li> +</ul> + +<h3 id="Embedded_content">Embedded content</h3> + +<ul> + <li><a href="/en-US/Learn/HTML/Howto/Embed_a_webpage_within_another_webpage">How to embed a webpage within another webpage</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Add_Flash_content_within_a_webpage">How to add Flash content within a webpage</a></li> +</ul> +</div> +</div> + +<h2 id="Uncommon_or_advanced_problems">Uncommon or advanced problems</h2> + +<p>Beyond the basics, HTML is very rich and offers advanced features for solving complex problems. These articles help you tackle the less common use cases you may face:</p> + +<div class="column-container"> +<div class="column-half"> +<h3 id="Forms">Forms</h3> + +<p>Forms are a complex HTML structure made to send data from a webpage to a web server. We encourage you to go over our <a href="/en-US/docs/Web/Guide/HTML/Forms">full dedicated guide</a>. Here is where you should start:</p> + +<ul> + <li><a href="/en-US/docs/Web/Guide/HTML/Forms/My_first_HTML_form">How to create a simple Web form</a></li> + <li><a href="/en-US/docs/Web/Guide/HTML/Forms/How_to_structure_an_HTML_form">How to structure a Web form</a></li> +</ul> + +<h3 id="Tabular_information">Tabular information</h3> + +<p>Some information, called tabular data, needs to be organized into tables with columns and rows. It's one of the most complex HTML structures, and mastering it is not easy:</p> + +<ul> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Create_a_data_spreadsheet">How to create a data spreadsheet</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Make_HTML_tables_accessible">How to make HTML tables accessible</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Optimize_HTML_table_rendering">How to optimize HTML table rendering</a></li> +</ul> + +<h3 id="Data_representation">Data representation</h3> + +<ul> + <li><a class="new" href="/en-US/Learn/HTMLHowto/Represent_numeric_values_with_HTML">How to represent numeric values with HTML</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Associate_human_readable_content_with_arbitrary_computer_data_structures">How to associate human readable content with arbitrary computer data structures</a></li> +</ul> + +<h3 id="Interactivity">Interactivity</h3> + +<ul> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Create_collapsible_content_with_HTML">How to create collapsible content with HTML</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Add_context_menus_to_a_webpage">How to add context menus to a webpage</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Create_dialog_boxes_with_HTML">How to create dialog boxes with HTML</a></li> +</ul> +</div> + +<div class="column-half"> +<h3 id="Advanced_text_semantics">Advanced text semantics</h3> + +<ul> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Take_control_of_HTML_line_breaking">How to take control of HTML line breaking</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Mark_text_insertion_and_deletion">How to mark changes (added and removed text)</a></li> +</ul> + +<h3 id="Advanced_images_multimedia">Advanced images & multimedia</h3> + +<ul> + <li><a href="/en-US/Learn/HTML/Howto/Add_responsive_image_to_a_webpage">How to add responsive image to a webpage</a></li> + <li><a href="/en-US/Learn/HTML/Howto/Add_vector_image_to_a_webpage">How to add vector image to a webpage</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Add_a_hit_map_on_top_of_an_image">How to add a hit map on top of an image</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Create_dynamic_and_interactive_images">How to create dynamic and interactive images</a></li> +</ul> + +<h3 id="Internationalization">Internationalization</h3> + +<p>HTML is not monolingual. It provides tools to handle common internationalization issues.</p> + +<ul> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Add_multiple_languages_into_a_single_webpage">How to add multiple languages into a single webpage</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Handle_Japanese_ruby_characters">How to handle Japanese ruby characters</a></li> + <li><a class="new" href="/en-US/Learn/HTML/Howto/Display_time_and_date_with_HTML">How to display time and date with HTML</a></li> +</ul> +</div> +</div> + +<p><span style="display: none;"> </span><span style="display: none;"> </span><span style="display: none;"> </span><span style="display: none;"> </span> </p> diff --git a/files/ms/learn/html/index.html b/files/ms/learn/html/index.html new file mode 100644 index 0000000000..826dc8c29c --- /dev/null +++ b/files/ms/learn/html/index.html @@ -0,0 +1,48 @@ +--- +title: HTML +slug: Learn/HTML +tags: + - Beginner + - CodingScripting + - HTML + - NeedsContent + - NeedsTranslation + - TopicStub +translation_of: Learn/HTML +--- +<div>{{IncludeSubnav("/en-US/Learn")}}</div> +<p>{{Glossary('HTML')}} is a major Web technology that defines the structure of a webpage. If you're looking to build websites, you should know about HTML.</p> + +<p>It's not hard to pick up the basics, but HTML is also a broad technology with many complex features, so there isn't one correct learning pathway. We suggest you start with the following pages to pick up some skills and knowledge. Move from the first basic skill to the last advanced skill, or just pick a page that looks interesting to you!</p> + +<div class="row topicpage-table"> +<div class="section"> +<h2 id="The_basics">The basics</h2> + +<p>Start here if you aren't familiar with HTML:</p> + +<dl> + <dt><a href="/en-US/docs/Web/Guide/HTML/Introduction">Introduction to HTML</a></dt> + <dd>If you've ever wondered what goes on behind the scenes in your Web browser, here's where you can start learning.</dd> + <dt><a href="/en-US/Learn/HTML/Howto">Solve common problems with HTML</a></dt> + <dd>This series of articles is here to help use HTML to solve very common problems when creating a webpage: Dealing with titles, adding images or videos, emphazing content, starting using form, etc.</dd> + <dt><a href="/en-US/Learn/HTML/Write_a_simple_page_in_HTML">Write a simple page in HTML</a></dt> + <dd>In this article you will learn how to create a simple webpage.</dd> + <dt><a href="/en-US/Learn/HTML/HTML_tags">What are HTML tags and how to use them</a></dt> + <dd>This article covers the very basics of HTML. Find out what tags are and how to use them.</dd> +</dl> +</div> + +<div class="section"> +<h2 id="In_depth">In depth</h2> + +<p>Once you're a bit more used to HTML, here's some more detailed stuff to explore:</p> + +<dl> + <dt><a href="/en-US/docs/Web/HTML/Reference">HTML reference</a></dt> + <dd>In our extensive reference guide, you'll find details about each HTML element and attribute.</dd> +</dl> +</div> +</div> + +<p> </p> diff --git a/files/ms/learn/index.html b/files/ms/learn/index.html new file mode 100644 index 0000000000..4140d61ab2 --- /dev/null +++ b/files/ms/learn/index.html @@ -0,0 +1,94 @@ +--- +title: Learning the Web +slug: Learn +tags: + - Beginner + - Index + - Landing + - Learn + - NeedsTranslation + - TopicStub + - Web +translation_of: Learn +--- +<div class="summary"> +<p><span style="font-size: 1.25rem;">anda mahu mencipta laman web dan aplikasi web anda sendiri? Anda telah datang ke tempat yang betul!</span></p> +</div> + +<p>Terdapat banyak perkara yang boleh dipelajari tentang rekabentuk dan pembangunan web, tapi jangan risau. Kami di sini untuk untuk membantu anda, sama ada anda hanya mahu mempelajari sedikit kod atau untuk menjadi pembangun web profesional sepenuhnya.</p> + +<h2 id="Ke_mana_dahulu">Ke mana dahulu</h2> + +<p>Penerangan yang mana terbaik melambangkan anda?</p> + +<ul class="card-grid" style="list-style-type: disc;"> + <li><span>Saya baru belajar</span> + + <p>Selamat datang! Tempat terbaik untuk bermula adalah siri <a href="https://developer.mozilla.org/ms/docs/Learn/Memulakan_pembelajaran_web">Mula Belajar Web</a>. Ia menyediakan semua asas-asas untuk membantu anda bermula dengan pembangunan Web.</p> + </li> + <li><span>Saya tahu Web</span> + <p>Sangat bagus! Kalau begitu kami cadangkan anda mula mendalami lebih dalam teknologi-teknologi Web : <a href="/en-US/docs/Learn/HTML">HTML</a>, <a href="/en-US/docs/Learn/CSS">CSS</a>, dcityan <a href="/en-US/docs/Learn/JavaScript">JavaScript</a></p> + </li> + <li><span>Saya sudah menguasai Web</span> + <p>Hebat! Kalau begitu anda mungkin berminat untuk meneroka <a href="https://developer.mozilla.org/en-US/docs/Web/Guide">Panduan </a>lanjutan dan <a href="https://developer.mozilla.org/en-US/docs/Web/Tutorials">Tutorial</a>. Anda juga boleh mempertimbangkan <a href="https://developer.mozilla.org/en-US/Learn/How_to_contribute">menyumbang kepada Bahagian Pembelajaran</a> ;)</p> + </li> +</ul> + +<div class="note"> +<p><strong>Nota: </strong>Pada masa hadapan kami merancang untuk menerbitkan lebih banyak laluan pembelajaran, sebagai contoh untuk programmer berpengalaman mempelajari teknik-teknik lanjutan yang spesifik, pembangun asli yang baru dengan Web, atau orang yang hendak belajar teknik-teknik rekabentuk.</p> +</div> + +<p>{{LearnBox({"title":"Quick learning: Vocabulary"})}}</p> + +<h2 id="Pembelajaran_dengan_orang_lain">Pembelajaran dengan orang lain</h2> + +<p>Jika anda ada soalan atau masih tertanya-tanya ke mana hendak dituju, Mozilla adalah komuniti global merangkumi peminat-peminat Web, termasuk mentor-mentor dan guru-guru yang sedia untuk membantu anda. Berhubunglah dengan mereka melalui WebMaker:</p> + +<ul> + <li>Bertemu dan berbincang dengan mentor dan guru di <a href="http://discourse.webmaker.org/">Forum Wacana</a>.</li> + <li><a href="https://events.webmaker.org/">Cari acara</a> dan belajar web dengan orang-orang hebat.</li> +</ul> + +<h2 id="Berkongsi_pengetahuan">Berkongsi pengetahuan</h2> + +<p>Seluruh bahagian pembelajaran ini dibina oleh penyumbang-penyumbang kami. Kami perlukan anda dalam pasukan kami sama ada anda baru bermula, seorang guru, atau seorang pembangun web berkemahiran. Jika anda berminat, cuba lihat di <a href="https://developer.mozilla.org/en-US/Learn/How_to_contribute">bagaimana anda boleh membantu</a>, dan kami menggalakkan anda untuk bersembang dengan kami di <a href="https://developer.mozilla.org/en-US/docs/MDN/Community#Join_our_mailing_lists">senarai mel</a> atau <a href="https://developer.mozilla.org/en-US/docs/MDN/Community#Get_into_IRC">saluran IRC</a>. :)</p> + +<h6 id="Subnav">Subnav</h6> + +<ol> + <li><a href="https://developer.mozilla.org/ms/docs/Learn/Memulakan_pembelajaran_web">Mula Mempelajari Web</a></li> + <li><a href="https://developer.mozilla.org/en-US/Learn/Skills">Belajar Web</a> + <ol> + <li><a href="https://webmaker.org/en-US/literacy" rel="external">Web Literacy Map</a></li> + <li><a href="/en-US/Learn/Web_Mechanics">Web mechanics</a></li> + <li><a href="/en-US/Learn/Infrastructure">Infrastructure</a></li> + <li><a href="/en-US/Learn/Coding-Scripting">Coding & Scripting</a></li> + <li><a href="/en-US/Learn/Design_and_Accessibility">Design & Accessibility</a></li> + <li><a href="/en-US/Learn/Composing_for_the_web">Writing & planning</a></li> + </ol> + </li> + <li><a href="https://developer.mozilla.org/ms/docs/Learn#">Belajar teknologi-teknologi</a> + <ol> + <li><a href="/en-US/Learn/HTML">HTML</a></li> + <li><a href="/en-US/Learn/CSS">CSS</a></li> + <li><a href="/en-US/Learn/JavaScript">JavaScript</a></li> + <li><a href="/en-US/Learn/Python">Python</a></li> + </ol> + </li> + <li><a href="https://developer.mozilla.org/en-US/Learn/tutorial">Tutorial pembelajaran</a> + <ol> + <li><a href="https://developer.mozilla.org/en-US/Learn/tutorial/How_to_build_a_web_site">Bagaimana mencipta sebuah laman web?</a></li> + <li><a href="https://developer.mozilla.org/en-US/Learn/tutorial/Information_Security_Basics">Asas keselamatan maklumat</a></li> + </ol> + </li> + <li><a href="http://weblitmapper.webmakerprototypes.org/">Rujukan pembelajaran</a></li> + <li><a href="https://developer.mozilla.org/en-US/Learn/help">Dapatkan bantuan</a> + <ol> + <li><a href="/en-US/Learn/FAQ">FAQ</a></li> + <li><a href="https://developer.mozilla.org/en-US/docs/Glossary">Glosari</a></li> + <li><a href="http://discourse.webmakerprototypes.org/">Tanyakan soalan-soalan anda</a></li> + <li><a href="https://events.webmaker.org/">Bertemu dengan guru dan mentor</a></li> + </ol> + </li> + <li><a href="https://developer.mozilla.org/en-US/Learn/How_to_contribute">Bagaimana untuk menyumbang</a></li> +</ol> diff --git a/files/ms/learn/memulakan_pembelajaran_web/berurusan_dengan_fail/index.html b/files/ms/learn/memulakan_pembelajaran_web/berurusan_dengan_fail/index.html new file mode 100644 index 0000000000..41e06b9599 --- /dev/null +++ b/files/ms/learn/memulakan_pembelajaran_web/berurusan_dengan_fail/index.html @@ -0,0 +1,103 @@ +--- +title: Berurusan dengan fail +slug: Learn/Memulakan_pembelajaran_web/Berurusan_dengan_fail +tags: + - Beginner + - CodingScripting + - Files + - Guide + - HTML + - theory + - website +translation_of: Learn/Getting_started_with_the_web/Dealing_with_files +--- +<div>{{LearnSidebar}}</div> + +<div>{{PreviousMenuNext("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web/HTML_basics", "Learn/Getting_started_with_the_web")}}</div> + +<div class="summary"> +<p>Sebuah laman web merangkumi banyak fail: kandungan teks, kod, stylesheet, kandungan media, dan sebagainya. Apabila anda membangunkan sebuah laman web, anda perlu menghimpunkan fail-fail ini dalam struktur yang wajar di komputer anda, pastikan fail-fail ini dapat berhubung antara satu sama lain, dan menjadikan kandungan anda nampak betul, sebelum anda akhirnya <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/Publishing_your_website">memuat naik ke pelayan</a>. Berurusan dengan fail membincangkan beberapa isu yang anda patut peka supaya anda boleh menetapkan struktur fail yang wajar untuk laman web anda.</p> +</div> + +<h2 id="Di_manakah_laman_web_anda_patut_berada_di_dalam_komputer_anda">Di manakah laman web anda patut berada di dalam komputer anda?</h2> + +<p>Apabila anda mengerjakan laman web anda di komputer anda sendiri, anda perlu menyimpan fail-fail yang berkaitan di dalam folder tunggal yang mirip dengan struktur fail untuk laman web yang diterbitkan di pelayan. Folder ini boleh berada di mana sahaja anda suka, tetapi anda patut letaknya di tempat yang anda mudah untuk menjumpainya, mungkin di Desktop anda, dalam folder Home, atau di root pemacu keras anda.</p> + +<ol> + <li>Pilih tempat untuk menyimpan projek-projek laman web anda. Di sini, cipta sebuah folder baru yang dinamakan <code>web-projects</code> (atau serupa). Di sinilah kesemua projek-projek laman web anda akan berada.</li> + <li>Di dalam folder pertama ini, cipta folder lain untuk menyimpan laman web pertama anda. Namakannya <code>test-site</code> (atau sesuatu yang lebih imaginatif).</li> +</ol> + +<h2 id="Catatan_tentang_casing_dan_spacing">Catatan tentang casing dan spacing</h2> + +<p>Anda akan perasan bahawa sepanjang artikel ini, kami meminta anda untuk menamakan folder-folder dan fail-fail sepenuhnya dalam huruf kecil tanpa jarak, Ini kerana:</p> + +<ol> + <li>Kebanyakan komputer, terutamanya pelayan web, adalah case-sensitive. Sebagai contoh, jika anda meletakkan sebuah imej di laman web anda di<code> test-site/MyImage.jpg</code>, dan dalam fail yang lain anda cuba untuk memanggil imej tersebut sebagai <code>test-site/myimage.jpg</code>, ia mungkin tidak berfungsi.</li> + <li>Pelayar-pelayar web, pelayan-pelayan web, dan bahasa-bahasa pengaturcaraan tidak mengendalikan ruang dengan konsisten. Sebagai contoh, jika anda menggunakan ruang di dalam nama fail, sesetengah sistem mungkin akan menganggap nama fail tersebut sebagai dua nama. Sesetengah pelayan akan menggantikan ruang tersebut di dalam nama fail anda dengan "%20"(kod karakter untuk ruang dalam URI), merosakkan kesemua pautan anda. Lebih baik untuk mengasingkan perkataan dengan tanda sempang atau garis bawah: <code>my-file.html</code> atau <code>my_file.html</code>.</li> +</ol> + +<p>Untuk sebab-sebab ini, ia adalah sangat baik untuk menjadikan tabiat menulis nama-nama folder dan fail dalam huruf kecil tanpa ruang, sekurang-kurangnya sehingga anda tahu apa yang anda buat. Dengan cara tersebut anda akan kurang terlibat dengan masalah.</p> + +<h2 id="Apakah_struktur_yang_patut_dimiliki_laman_web_anda">Apakah struktur yang patut dimiliki laman web anda?</h2> + +<p>Seterusnya, mari lihat struktur apa yang laman web kita patut ada. Benda asas utama yang kita akan ada dalam apa-apa projek laman web yang kita cipta adalah fail index HTML dan folder-folder untuk menyimpan imej-imej, fail-fail style, dan fail-fail script. Mari kita cipta ini sekarang:</p> + +<ol> + <li><code><strong>index.html</strong></code>: Secara umumnya fail ini mengandungi kandungan halaman utama, iaitu teks dan imej-imej yang dilihat orang apabila mereka mula-mula pergi ke laman anda. Dengan menggunakan editor teks anda, cipta fail baru dinamakan <code>index.html</code> dan simpan ia di dalam folder <code>test-site</code> anda.</li> + <li><strong><code>folder images</code></strong>: Folder ini akan mengandungi kesemua imej yang anda gunakan di laman anda. Cipta sebuah folder dinamakan <code>images</code>, di dalam folder <code>test-site anda.</code></li> + <li><strong><code>folder styles</code></strong>: Folder ini akan mengandungi kod CSS yang digunakan untuk mengayakan kandungan anda (sebagai contoh, menetapkan teks dan warna-warna latar belakang). Cipta sebuah folder dinamakan <code>styles</code>, di dalam folder <code>test-site anda.</code></li> + <li><strong><code>folder scripts</code></strong>: Folder ini akan mengandungi kesemua kod JavaScript yang digunakan untuk menambah fungsi interaktif ke dalam laman anda (cth. button yang memuatkan data apabila diklik). Cipta sebuah folder dinamakan <code>scripts</code>, di dalam folder <code>test-site anda.</code></li> +</ol> + +<div class="note"> +<p><strong>Nota</strong>: Dalam komputer Windows, anda mungkin menghadapi masalah melihat nama-nama fail kerana Windows mempunyai satu pilihan yang menjengkelkan dinamakan <strong>Hide extensions for known file types </strong>yang dihidupkan secara default. Secara umumnya, anda boleh mematikannya dengan pergi ke Windows Explorer, memilih pilihan <strong>Folder options...</strong>, menyahtik pada kotak pilihan <strong>Hide extensions for known file types</strong>, kemudian klik <strong>OK</strong>. Untuk maklumat spesifik merangkumi versi Windows anda, lakukan carian Yahoo!</p> +</div> + +<h2 id="Path_fail">Path fail</h2> + +<p>Untuk membuat fail-fail berhubung antara satu sama lain, anda perlu menyediakan path antara mereka — secara asasnya sebuah route supaya satu fail tahu di mana fail yang satu lagi. Untuk mendemonstrasikan ini, kita akan memasukkan sedikit HTML ke dalam fail <code>index.html</code>, dan membuatkan ia memaparkan imej yang anda pilih di dalam artikel "Bagaimanakah laman web anda akan kelihatan?"</p> + +<ol> + <li>Salin imej yang anda pilih sebelum ini ke dalam folder <code>images</code> anda.</li> + <li>Buka fail <code>index.html</code> anda, dan masukkan kod di bawah ke dalam fail yang ditunjukkan. Jangan risau tentang apa semua maksud ini buat masa sekarang — kita akan lihat dengan lebih terperinci pada strukturnya nanti dalam siri tersebut. + <pre class="brush: html"><!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>My test page</title> + </head> + <body> + <img src="" alt="My test image"> + </body> +</html> </pre> + </li> + <li>Baris <code><img src="" alt="My test image"></code> adalah kod HTML yang memasukkan sebuah gambar ke dalam laman tersebut. Kita perlu beritahu HTML di mana gambar tersebut. Imej tersebut berada dalam direktori <em>images</em> , yang mana dalam direktori sama seperti <code>index.html</code>. Untuk menelusuri struktur fail daripada <code>index.html</code> kepada imej kita, path fail yang kita perlukan adalah <code>images/nama-failimej-anda</code>. Sebagai contoh, imej kita dinamakan <code>firefox-icon.png</code>, jadi path fail adalah <code>images/firefox-icon.png</code>.</li> + <li>Masukkan path fail ke dalam kod HTML di antara tanda petikan berganda kod <code>src=""</code>.</li> + <li>Save fail HTML anda, kemudian muatkannya di pelayar web anda (klik dua kali fail tersebut). Anda patut boleh lihat halaman web baru anda memaparkan imej anda!</li> +</ol> + +<p><img alt="A screenshot of our basic website showing just the firefox logo - a flaming fox wrapping the world" src="https://mdn.mozillademos.org/files/9229/website-screenshot.png" style="display: block; height: 542px; margin: 0px auto; width: 690px;"></p> + +<p>Beberapa peraturan umum untuk path fail:</p> + +<ul> + <li>Untuk menghubungkan fail sasaran di dalam direktori yang sama dengan fail HTML yang memanggilnya, cuma guna nama fail, cth. <code>imej-saya.jpg.</code></li> + <li>Untuk merujuk fail di dalam subdirektori, tulis nama direktori tersebut di hadapan path, tambahan tanda palang ke hadapan, cth. <code>subdirektori/imej-saya.jpg</code>.</li> + <li>Untuk menghubungkan fail sasaran di dalam direktori di atas fail HTML yang memanggil, tulis dua titik. Jadi sebagai contoh, jika <code>index.html</code> berada dalam subfolder <code>test-site</code> dan <code>imej-saya.png berada dalam test-site, </code>anda boleh merujuk <code>imej-saya.png </code>daripada <code>index.html menggunakan </code> <code>../imej-saya.png</code>. <code> </code></li> + <li>Anda boleh menggabungkan ini sebanyak mungkin yang anda suka, sebagai contoh <code>../subdirektori/subdirektori-lain/imej-saya.png</code>.</li> +</ul> + +<p>Buat masa ini, ini adalah antara kesemua yang anda perlu tahu.</p> + +<div class="note"> +<p><strong>Nota</strong>: Sistem fail Windows cenderung untuk menggunakan garis palang terbalik, bukannya garis palang ke hadapan, cth. <code>C:\windows</code>. Ini tidak penting — walaupun anda membangunkan laman web anda dengan Windows, anda masih perlu menggunakan garis palang ke hadapan di dalam kod anda.</p> +</div> + +<h2 id="Apakah_lagi_yang_perlu_diselesaikan">Apakah lagi yang perlu diselesaikan?</h2> + +<p>Cukup lah buat masa ini. Struktur folder anda patut kelihatan seperti ini:</p> + +<p><img alt="A file structure in mac os x finder, showing an images folder with an image in, empty scripts and styles folders, and an index.html file" src="https://mdn.mozillademos.org/files/9231/file-structure.png" style="display: block; height: 577px; margin: 0px auto; width: 929px;"></p> + +<p>{{PreviousMenuNext("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web/HTML_basics", "Learn/Getting_started_with_the_web")}}</p> diff --git a/files/ms/learn/memulakan_pembelajaran_web/index.html b/files/ms/learn/memulakan_pembelajaran_web/index.html new file mode 100644 index 0000000000..fd07a2d78a --- /dev/null +++ b/files/ms/learn/memulakan_pembelajaran_web/index.html @@ -0,0 +1,57 @@ +--- +title: Memulakan pembelajaran Web +slug: Learn/Memulakan_pembelajaran_web +tags: + - Beginner + - CSS + - Design + - Guide + - HTML + - Index + - publishing + - theory +translation_of: Learn/Getting_started_with_the_web +--- +<div>{{LearnSidebar}}</div> + +<div class="summary"> +<p><em><strong>Memulakan pembelajaran Web</strong></em> adalah siri ringkas dan padat memperkenalkan anda kepada praktikaliti pembangunan Web. Anda akan menetapkan alatan yang anda perlukan untuk membina halaman web dan menerbitkan kod ringkas anda sendiri.</p> +</div> + +<h2 id="Kisah_laman_web_pertama_anda">Kisah laman web pertama anda</h2> + +<p>Ia adalah banyak kerja untuk mencipta laman web yang profesional, jadi jika anda masih baru dalam pembangunan web kami menggalakkan anda supaya bermula daripada bawah. Anda tidak akan mendirikan sebuah lagi Facebook dengan serta merta, namun ianya bukan susah untuk menerbitkan laman web ringkas anda sendiri ke dalam talian, jadi kita akan bermula daripada situ.</p> + +<p>Dengan berusaha menerusi artikel-artikel yang disenaraikan mengikut urutan di bawah, anda akan bermula daripada tiada kepada menerbitkan halaman web pertama anda ke dalam talian. Jadi mari kita bermula!</p> + +<h3 id="Memasang_perisian_asas"><a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/Installing_basic_software">Memasang perisian asas</a></h3> + +<p>Apabila datang kepada soal alatan untuk membina laman web, terdapat banyak pilihan yang boleh dipilih. Jika anda baru sahaja bermula, anda mungkin akan keliru dengan pelbagai jenis editor kod, kerangka kerja, dan alatan pengujian di luar sana. Dalam artikel <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/Installing_basic_software">Memasang perisian asas </a>kami menunjukkan anda langkah demi langkah bagaimana untuk memasang hanya perisian yang anda perlukan untuk memulakan sedikit pembangunan asas web.</p> + +<h3 id="Bagaimana_laman_web_anda_akan_kelihatan"><a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/What_will_your_website_look_like">Bagaimana laman web anda akan kelihatan?</a></h3> + +<p>Sebelum anda mula menulis kod untuk laman web anda, anda patut rancang ia dahulu. Apakah maklumat yang anda hendak tunjuk? Apa font dan warna yang anda gunakan? <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/What_will_your_website_look_like">Bagaimana laman web anda akan kelihatan? </a>Kami akan mengariskan cara mudah yang anda boleh ikut untuk merancang kandungan dan rekabentuk laman web anda.</p> + +<h3 id="Berurusan_dengan_fail-fail"><a href="/en-US/Learn/Getting_started_with_the_web/Dealing_with_files">Berurusan dengan fail-fail</a></h3> + +<p>Sebuah laman web merangkumi banyak fail: kandungan teks, kod, lembaran gaya, kandungan media, dan seterusnya. Apabila anda membina sebuah laman web, anda perlu menghimpunkan fail-fail ini ke dalam struktur yang wajar dan memastikan fail-fail ini dapat berhubung antara satu sama lain. <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/Dealing_with_files">Berurusan dengan fail-fail</a> menerangkan bagaimana untuk menetapkan struktur fail yang wajar untuk laman web anda dan isu-isu yang anda perlu sedar.</p> + +<h3 id="Asas-asas_HTML"><a href="/en-US/Learn/Getting_started_with_the_web/HTML_basics">Asas-asas HTML</a></h3> + +<p>Hypertext Markup Language (HTML) adalah kod yang anda guna untuk mengstrukturkan kandungan web anda, dan memberinya makna dan tujuan. Sebagai contoh, adakah kandungan saya adalah satu set perenggan, atau satu senarai titik bullet? Adakah saya ada gambar-gambar di dalam halaman saya? Adakah saya ada jadual data? Tanpa membebankan anda, <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/HTML_basics">Asas-asas HTML </a>menyediakan maklumat yang cukup untuk membiasakan diri anda dengan HTML.</p> + +<h3 id="Asas-asas_CSS"><a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/CSS_basics">Asas-asas CSS</a></h3> + +<p>Cascading Stylesheet (CSS) adalah kod yang anda guna untuk menggayakan laman web anda. Sebagai contoh, adakah anda mahu teks hitam atau merah? Di manakah kandungan patut dilukis di atas skrin? Apakah gambar dan warna latar belakang yang patut digunakan untuk menghias laman web anda? <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/CSS_basics">Asas-asas CSS </a>akan membawa anda menelusuri apa yang anda perlukan untuk bermula.</p> + +<h3 id="Asas-asas_JavaScript"><a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/JavaScript_basics">Asas-asas JavaScript</a></h3> + +<p>JavaScript adalah bahasa pengaturcaraan yang anda guna untuk menambah ciri-ciri interaktif kepada laman web anda, sebagai contoh, permainan, perkara yang berlaku apabila butang ditekan atau data dihantar dalam borang, kesan penggayaan dinamik, animasi, dan banyak lagi. <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/JavaScript_basics">Asas-asas JavaScript</a> memberi anda idea apa yang boleh dibuat dengan bahasa yang menarik ini, dan bagaimana untuk bermula.</p> + +<h3 id="Menerbitkan_laman_web_anda"><a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/Publishing_your_website">Menerbitkan laman web anda</a></h3> + +<p>Sebaik sahaja anda siap menulis kod dan menyusun fail-fail yang menjadikan laman web anda, anda perlu meletakkan semuanya di atas talian supaya orang boleh menjumpainya. <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/Publishing_your_website">Menerbitkan kod sampel anda</a> menerangkan bagaimana untuk meletakkan kod sampel ringkas anda di atas talian dengan usaha yang sedikit.</p> + +<h3 id="Bagaimana_web_berfungsi"><a href="/en-US/Learn/Getting_started_with_the_web/How_the_Web_works">Bagaimana web berfungsi</a></h3> + +<p>Apabila anda mengakses laman web kegemaran anda, banyak perkara yang merumitkan berlaku di belakang yang anda mungkin tidak tahu. <a href="https://developer.mozilla.org/en-US/Learn/Getting_started_with_the_web/How_the_Web_works">Bagaimana web berfungsi</a> menggariskan apa yang berlaku apabila anda melihat paparan halaman web di komputer anda.</p> diff --git a/files/ms/learn/memulakan_pembelajaran_web/memasang_perisian_asas/index.html b/files/ms/learn/memulakan_pembelajaran_web/memasang_perisian_asas/index.html new file mode 100644 index 0000000000..2363f77c32 --- /dev/null +++ b/files/ms/learn/memulakan_pembelajaran_web/memasang_perisian_asas/index.html @@ -0,0 +1,58 @@ +--- +title: Memasang Perisian Asas +slug: Learn/Memulakan_pembelajaran_web/Memasang_Perisian_Asas +tags: + - Beginner + - Browser + - Learn + - Setup + - Tools + - WebMechanics + - text editor +translation_of: Learn/Getting_started_with_the_web/Installing_basic_software +--- +<div>{{LearnSidebar}}</div> + +<div>{{NextMenu("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web")}}</div> + +<div class="summary"> +<p>Dalam artikel <em><strong>Memasang Perisian Asas</strong></em>, kami akan tunjuk anda alatan yang anda perlukan untuk melakukan pembangunan web yang mudah.</p> +</div> + +<h2 id="Apakah_alatan_yang_digunakan_profesional">Apakah alatan yang digunakan profesional?</h2> + +<ul> + <li><strong>Sebuah komputer</strong>.Mungkin itu kedengaran jelas bagi sesetengah orang, tetapi sesetengah daripada anda membaca artikel ini daripada telefon atau komputer perpustakaan. Untuk pembangunan web yang serius, ia adalah lebih baik untuk melabur untuk sebuah komputer desktop (Windows, Mac, Linux).</li> + <li><strong>Editor teks</strong>,untuk menulis kod. Boleh jadi editor teks percuma (contohnya <a href="http://notepad-plus-plus.org/">Notepad++</a>, <a href="https://wiki.gnome.org/Apps/Gedit">gedit</a>, <a href="http://brackets.io/">Brackets</a>, <a href="https://atom.io/">Atom</a> or <a href="http://www.barebones.com/products/textwrangler/">Text Wrangler</a>), editor teks komersial (<a href="http://www.sublimetext.com/">Sublime Text</a> atau <a href="https://panic.com/coda/">Coda</a>) atau editor hibrid (<a href="https://www.adobe.com/products/dreamweaver.html">Dreamweaver</a>).</li> + <li><strong>Pelayar Web </strong>,untuk menguji kod. Pada masa ini, pelayar yang selalu digunakan adalah <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>, <a href="https://www.google.com/chrome/browser/">Chrome</a>, <a href="http://www.opera.com/">Opera</a>, <a href="https://www.apple.com/safari/">Safari</a>, dan <a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie">Internet Explorer</a>.</li> + <li><strong>Editor grafik</strong>, seperti <a href="http://www.gimp.org/">GIMP</a>, <a href="http://www.getpaint.net/">Paint.NET</a>, atau <a href="https://www.adobe.com/products/photoshop.html">Photoshop</a>, untuk membuat gambar-gambar untuk halaman-halaman web anda..</li> + <li><strong>Sistem kawalan versi</strong>, untuk berkolaborasi dalam projek yang melibatkan pasukan, berkongsi kod dan aset, dan mengelak konflik pengeditan. Pada masa ini <a href="http://git-scm.com/">Git</a> adalah alat kawalan versi paling terkenal, begitu juga servis hosting kod <a href="https://github.com/">GitHub</a>, yang berasaskan Git, juga agak terkenal.</li> + <li><strong>Program FTP</strong>, untuk memuat naik halaman-halaman web ke pelayan untuk paparan umum. Terdapat banyak program-program ini termasuk <a href="https://cyberduck.io/">Cyberduck</a>, <a href="http://fetchsoftworks.com/">Fetch</a>, <a href="https://filezilla-project.org/">FileZilla</a>.</li> + <li><strong>Sistem automasi</strong>, seperti <a href="http://gruntjs.com/">Grunt</a> atau <a href="http://gulpjs.com/">Gulp</a>, untuk melaksanakan tugas yang berulang-ulang secara automatik. Sebagai contoh, mengurangkan kod dan menjalankan ujian-ujian.</li> + <li>Templat, library, kerangka kerja, dan lain-lain, untuk mempercepatkan penulisan fungsi lazim.</li> + <li>Lebih banyak alatan lain!</li> +</ul> + +<h2 id="Apakah_alatan_yang_saya_perlukan_sekarang">Apakah alatan yang saya perlukan sekarang?</h2> + +<p>Itu kelihatan seperti senarai yang menakutkan, tetapi nasib baik anda boleh memulakan pembangunan web tanpa mengetahui apa-apa tentang kebanyakan alatan di atas. Dalam artikel ini kami akan menetapkan anda dengan seminimun alatan — editor teks dan beberapa pelayar web moden.</p> + +<h3 id="Memasang_editor_teks">Memasang editor teks</h3> + +<p>Anda mungkin sudah ada editor teks asas dalam komputer anda. Secara lalai Windows merangkumi Notepad dan OS X datang dengan TextEdit. Distro Linx bergantung, Ubuntu dalam dengan gedit secara lalai.</p> + +<p>Untuk pembangunan Web, anda mungkin boleh buat lebih baik daripada Notepad atau TextEdit. Kami menyarankan anda bermula dengan <a href="http://notepad-plus-plus.org/">Notepad++</a> untuk Windows atau <a href="http://www.barebones.com/products/textwrangler/">Text Wrangler</a> untuk Mac. Kedua-duanya percuma dan lebih berciri penuh berbanding Notepad dan TextEdit.</p> + +<h3 id="Memasang_pelayar-pelayar_web_moden">Memasang pelayar-pelayar web moden</h3> + +<p>Buat masa ini, kita hanya pasang beberapa pelayar web desktop untuk menguji kod kita di dalamnya. Pilih sistem operasi anda di bawah dan klik pautan yang relevan untuk memuat turun pemasang-pemasang pelayar kegemaran anda:</p> + +<ul> + <li>Linux: <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>, <a href="https://www.google.com/chrome/browser/">Chrome</a>, <a href="http://www.opera.com/">Opera</a>.</li> + <li>Windows: <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>, <a href="https://www.google.com/chrome/browser/">Chrome</a>, <a href="http://www.opera.com/">Opera</a>, <a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie">Internet Explorer</a> (Jika anda ada Windows 8 atau ke atas, anda boleh memasang IE 10 dan ke atas; jika tidak, anda patut pasang pelayar alternatif lain)</li> + <li>Mac: <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>, <a href="https://www.google.com/chrome/browser/">Chrome</a>, <a href="http://www.opera.com/">Opera</a>, <a href="https://www.apple.com/safari/">Safari</a> (Safari datang dengan iOS dan OS X secara lalai)</li> +</ul> + +<p>Sebelum meneruskan, anda patut pasang sekurang-kurangnya dua daripada pelayar-pelayar ini dan sediakannya untuk pengujian.</p> + +<p>{{NextMenu("Learn/Getting_started_with_the_web/What_will_your_website_look_like", "Learn/Getting_started_with_the_web")}}</p> diff --git a/files/ms/learn/server-side/express_nodejs/forms/index.html b/files/ms/learn/server-side/express_nodejs/forms/index.html new file mode 100644 index 0000000000..6e50f7b27a --- /dev/null +++ b/files/ms/learn/server-side/express_nodejs/forms/index.html @@ -0,0 +1,276 @@ +--- +title: 'Express Tutorial Part 6: Working with forms' +slug: Learn/Server-side/Express_Nodejs/forms +tags: + - Beginner + - CodingScripting + - Express + - Forms + - HTML forms + - Learn + - NeedsTranslation + - Node + - TopicStub + - server-side +translation_of: Learn/Server-side/Express_Nodejs/forms +--- +<div>{{LearnSidebar}}</div> + +<div>{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/Displaying_data", "Learn/Server-side/Express_Nodejs/deployment", "Learn/Server-side/Express_Nodejs")}}</div> + +<p class="summary">In this tutorial we'll show you how to work with HTML Forms in Express, using Pug, and in particular how to write forms to create, update, and delete documents from the database.</p> + +<table class="learn-box standard-table"> + <tbody> + <tr> + <th scope="row">Prerequisites:</th> + <td>Complete all previous tutorial topics, including <a href="/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data">Express Tutorial Part 5: Displaying library data</a></td> + </tr> + <tr> + <th scope="row">Objective:</th> + <td>To understand how write forms to get data from users, and update the database with this data.</td> + </tr> + </tbody> +</table> + +<h2 id="Overview">Overview</h2> + +<p>An <a href="/en-US/docs/Web/Guide/HTML/Forms">HTML Form</a> is a group of one or more fields/widgets on a web page that can be used to collect information from users for submission to a server. Forms are a flexible mechanism for collecting user input because there are suitable form inputs available for entering many different types of data—text boxes, checkboxes, radio buttons, date pickers, etc. Forms are also a relatively secure way of sharing data with the server, as they allow us to send data in <code>POST</code> requests with cross-site request forgery protection.</p> + +<p>Working with forms can be complicated! Developers need to write HTML for the form, validate and properly sanitize entered data on the server (and possibly also in the browser), repost the form with error messages to inform users of any invalid fields, handle the data when it has successfully been submitted, and finally respond to the user in some way to indicate success.</p> + +<p>In this tutorial we're going to show you how the above operations may be performed in <em>Express</em>. Along the way we'll extend the <em>LocalLibrary</em> website to allow users to create, edit and delete items from the library.</p> + +<div class="note"> +<p><strong>Note:</strong> We haven't looked at how to restrict particular routes to authenticated or authorised users, so at this point any user will be able to make changes to the database.</p> +</div> + +<h3 id="HTML_Forms">HTML Forms</h3> + +<p>First a brief overview of <a href="/en-US/docs/Web/Guide/HTML/Forms">HTML Forms</a>. Consider a simple HTML form, with a single text field for entering the name of some "team", and its associated label:</p> + +<p><img alt="Simple name field example in HTML form" src="https://mdn.mozillademos.org/files/14117/form_example_name_field.png" style="border-style: solid; border-width: 1px; display: block; height: 44px; margin: 0px auto; width: 399px;"></p> + +<p>The form is defined in HTML as a collection of elements inside <code><form>...</form></code> tags, containing at least one <code>input</code> element of <code>type="submit"</code>.</p> + +<pre class="brush: html"><form action="/team_name_url/" method="post"> + <label for="team_name">Enter name: </label> + <input id="team_name" type="text" name="name_field" value="Default name for team."> + <input type="submit" value="OK"> +</form></pre> + +<p>While here we have included just one (text) field for entering the team name, a form <em>may</em> contain any number of other input elements and their associated labels. The field's <code>type</code> attribute defines what sort of widget will be displayed. The <code>name</code> and <code>id</code> of the field are used to identify the field in JavaScript/CSS/HTML, while <code>value</code> defines the initial value for the field when it is first displayed. The matching team label is specified using the <code style="font-style: normal; font-weight: normal;">label</code> tag (see "Enter name" above), with a <code style="font-style: normal; font-weight: normal;">for</code> field containing the <code style="font-style: normal; font-weight: normal;">id</code> value of the associated <code style="font-style: normal; font-weight: normal;">input</code>.</p> + +<p>The <code>submit</code> input will be displayed as a button (by default)—this can be pressed by the user to upload the data contained by the other input elements to the server (in this case, just the <code>team_name</code>). The form attributes define the HTTP <code>method</code> used to send the data and the destination of the data on the server (<code>action</code>):</p> + +<ul> + <li><code>action</code>: The resource/URL where data is to be sent for processing when the form is submitted. If this is not set (or set to an empty string), then the form will be submitted back to the current page URL.</li> + <li><code>method</code>: The HTTP method used to send the data: <code>POST</code> or <code>GET</code>. + <ul> + <li>The <code>POST</code> method should always be used if the data is going to result in a change to the server's database, because this can be made more resistant to cross-site forgery request attacks.</li> + <li>The <code>GET</code> method should only be used for forms that don't change user data (e.g. a search form). It is recommended for when you want to be able to bookmark or share the URL.</li> + </ul> + </li> +</ul> + +<h3 id="Form_handling_process">Form handling process</h3> + +<p>Form handling uses all of the same techniques that we learned for displaying information about our models: the route sends our request to a controller function which performs any database actions required, including reading data from the models, then generates and returns an HTML page. What makes things more complicated is that the server also needs to be able to process data provided by the user, and redisplay the form with error information if there are any problems.</p> + +<p>A process flowchart for processing form requests is shown below, starting with a request for a page containing a form (shown in green):<img alt="" src="https://mdn.mozillademos.org/files/14478/Web%20server%20form%20handling.png" style="height: 649px; width: 800px;"></p> + +<p>As shown in the diagram above, the main things that form handling code needs to do are are:</p> + +<ol> + <li>Display the default form the first time it is requested by the user. + <ul> + <li>The form may contain blank fields (e.g. if you're creating a new record), or it may be pre-populated with initial values (e.g. if you are changing a record, or have useful default initial values).</li> + </ul> + </li> + <li>Receive data submitted by the user, usually in an HTTP <code>POST</code> request.</li> + <li>Validate and sanitize the data.</li> + <li>If any data is invalid, re-display the form—this time with any user populated values and error messages for the problem fields.</li> + <li>If all data is valid, perform required actions (e.g. save the data in the database, send a notification email, return the result of a search, upload a file, etc.)</li> + <li>Once all actions are complete, redirect the user to another page.</li> +</ol> + +<p>Often form handling code is implemented using a <code>GET</code> route for the initial display of the form and a <code>POST</code> route to the same path for handling validation and processing of form data. This is the approach that will be used in this tutorial!</p> + +<p>Express itself doesn't provide any specific support for form handling operations, but it can use middleware to process <code>POST</code> and <code>GET</code> parameters from the form, and to validate/sanitize their values.</p> + +<h3 id="Validation_and_sanitization">Validation and sanitization</h3> + +<p>Before the data from a form is stored it must be validated and sanitized:</p> + +<ul> + <li>Validation checks that entered values are appropriate for each field (are in the right range, format, etc.) and that values have been supplied for all required fields.</li> + <li>Sanitization removes/replaces characters in the data that might potentially be used to send malicious content to the server.</li> +</ul> + +<p>For this tutorial we'll be using the popular <a href="https://www.npmjs.com/package/express-validator">express-validator</a> module to perform both validation and sanitization of our form data.</p> + +<h4 id="Installation">Installation</h4> + +<p>Install the module by running the following command in the root of the project.</p> + +<pre class="brush: bash">npm install express-validator --save +</pre> + +<h4 id="Using_express-validator">Using express-validator</h4> + +<div class="note"> +<p><strong>Note:</strong> The <a href="https://github.com/ctavan/express-validator#express-validator">express-validator</a> guide on Github provides a good overview of API. We recommend you read that to get an idea of all its capabilities (including creating custom validators). Below we cover just a subset that is useful for the <em>LocalLibrary</em>.</p> +</div> + +<p>To use the validator in our controllers we have to <em>require</em> the functions we want to use from the <strong>'express-validator/check</strong>' and <strong>'express-validator/filter</strong>' modules, as shown below:</p> + +<pre class="brush: js">const { body,validationResult } = require('express-validator/check'); +const { sanitizeBody } = require('express-validator/filter'); +</pre> + +<p>There are many functions available, allowing you to check and sanitize data from request parameters, body, headers, cookies, etc., or all of them at once. For this tutorial, we'll primarily be using <code>body</code>, <code>sanitizeBody</code>, and <code>validationResult</code> (as "required" above).</p> + +<p>The functions are defined as below:</p> + +<ul> + <li><code><a href="https://github.com/ctavan/express-validator#bodyfields-message">body(fields[, message])</a></code>: Specifies a set of fields in the request body (a <code>POST</code> parameter) to validate along with an optional error message that can be displayed if it fails the tests. The validation criteria are daisy-chained to the <code>body()</code> method. For example, the first check below tests that the "name" field is not empty and sets an error message "Empty name" if it is not. The second test checks that the age field is a valid date, and using <code>optional()</code> to specify that null and empty strings will not fail validation. + + <pre class="brush: js">body('name', 'Empty name').isLength({ min: 1 }), +body('age', 'Invalid age').optional({ checkFalsy: true }).isISO8601(), +</pre> + You can also daisy chain different validators, and add messages that are displayed if the preceding validators are true. + + <pre class="brush: js">body('name').isLength({ min: 1 }).trim().withMessage('Name empty.') + .isAlpha().withMessage('Name must be alphabet letters.'), +</pre> + + <div class="note"> + <p><strong>Note:</strong> You can also add inline sanitizers like <code>trim()</code>, as shown above. However sanitizers applied here ONLY apply to the validation step. If you want the final output sanitized, you need to use a separate sanitizer method, as shown below.</p> + </div> + </li> + <li><code><a href="https://github.com/ctavan/express-validator#sanitizebodyfields">sanitizeBody(fields)</a></code>: Specifies a body field to sanitize. The sanitization operations are then daisy-chained to this method. For example, the <code>escape()</code> sanitization operation below removes HTML characters from the name variable that might be used in JavaScript cross-site scripting attacks. + <pre class="brush: js">sanitizeBody('name').trim().escape(), +sanitizeBody('date').toDate(),</pre> + </li> + <li><code><a href="https://github.com/ctavan/express-validator#validationresultreq">validationResult(req)</a></code>: Runs the validation, making errors available in the form of a <code>validation</code> result object. This is invoked in a separate callback, as shown below: + <pre class="brush: js">(req, res, next) => { + // Extract the validation errors from a request. + const errors = validationResult(req); + + if (!errors.isEmpty()) { + // There are errors. Render form again with sanitized values/errors messages. + // Error messages can be returned in an array using `errors.array()`. + } + else { + // Data from form is valid. + } +}</pre> + We use the validation result's <code>isEmpty()</code> method to check if there were errors, and its <code>array()</code> method to get the set of error messages. See the <a href="https://github.com/ctavan/express-validator#validation-result-api">Validation Result API</a> for more information.</li> +</ul> + +<p>The validation and sanitization chains are middleware that should be passed to the Express route handler (we do this indirectly, via the controller). When the middleware runs, each validator/sanitizer is run in the order specified.</p> + +<p>We'll cover some real examples when we implement the <em>LocalLibrary</em> forms below.</p> + +<h3 id="Form_design">Form design</h3> + +<p>Many of the models in the library are related/dependent—for example, a <code>Book</code> <em>requires</em> an <code>Author</code>, and <em>may</em> also have one or more <code>Genres</code>. This raises the question of how we should handle the case where a user wishes to:</p> + +<ul> + <li>Create an object when its related objects do not yet exist (for example, a book where the author object hasn't been defined).</li> + <li>Delete an object that is still being used by another object (so for example, deleting a <code>Genre</code> that is still being used by a <code>Book</code>).</li> +</ul> + +<p>For this project we will simplify the implementation by stating that a form can only:</p> + +<ul> + <li>Create an object using objects that already exist (so users will have to create any required <code>Author</code> and <code>Genre</code> instances before attempting to create any <code>Book</code> objects).</li> + <li>Delete an object if it is not referenced by other objects (so for example, you won't be able to delete a <code>Book</code> until all associated <code>BookInstance</code> objects have been deleted).</li> +</ul> + +<div class="note"> +<p><strong>Note:</strong> A more "robust" implementation might allow you to create the dependent objects when creating a new object, and delete any object at any time (for example, by deleting dependent objects, or by removing references to the deleted object from the database).</p> +</div> + +<h3 id="Routes">Routes</h3> + +<p>In order to implement our form handling code we will need two routes that have the same URL pattern. The first (<code>GET</code>) route is used to display a new empty form for creating the object. The second route (<code>POST</code>) is used for validating data entered by the user, and then saving the information and redirecting to the detail page (if the data is valid) or redisplaying the form with errors (if the data is invalid).</p> + +<p>We have already created the routes for all our model's create pages in <strong>/routes/catalog.js</strong> (in a <a href="https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/routes">previous tutorial</a>). For example, the genre routes are shown below:</p> + +<pre class="brush: js">// GET request for creating a Genre. NOTE This must come before route that displays Genre (uses id). +router.get('/genre/create', genre_controller.genre_create_get); + +// POST request for creating Genre. +router.post('/genre/create', genre_controller.genre_create_post); +</pre> + +<h2 id="Express_forms_subarticles">Express forms subarticles</h2> + +<p>The following subarticles will take us through the process of adding the required forms to out example application. You need to read and work through each one in turn, before moving on to the next one.</p> + +<ol> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/forms/Create_genre_form">Create Genre form</a> — Defining our page to create <code>Genre</code> objects.</li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/forms/Create_author_form">Create Author form</a> — Defining a page for creating <code>Author</code> objects.</li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/forms/Create_book_form">Create Book form</a> — Defining a page/form to create <code>Book</code> objects.</li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/forms/Create_BookInstance_form">Create BookInstance form</a> — Defining a page/form to create <code>BookInstance</code> objects.</li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/forms/Delete_author_form">Delete Author form</a> — Defining a page to delete <code>Author</code> objects.</li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/forms/Update_Book_form">Update Book form</a> — Defining page to update <code>Book</code> objects.</li> +</ol> + +<h2 id="Challenge_yourself">Challenge yourself</h2> + +<p>Implement the delete pages for the <code>Book</code>, <code>BookInstance</code>, and <code>Genre</code> models, linking them from the associated detail pages in the same way as our <em>Author delete </em>page. The pages should follow the same design approach:</p> + +<ul> + <li>If there are references to the object from other objects, then these other objects should be displayed along with a note that this record can't be deleted until the listed objects have been deleted.</li> + <li>If there are no other references to the object then the view should prompt to delete it. If the user presses the <strong>Delete</strong> button, the record should then be deleted.</li> +</ul> + +<p>A few tips:</p> + +<ul> + <li>Deleting a <code>Genre</code> is just like deleting an <code>Author</code> as both objects are dependencies of <code>Book</code> (so in both cases you can delete the object only when the associated books are deleted).</li> + <li>Deleting a <code>Book</code> is also similar, but you need to check that there are no associated <code>BookInstances</code>.</li> + <li>Deleting a <code>BookInstance</code> is the easiest of all, because there are no dependent objects. In this case you can just find the associated record and delete it.</li> +</ul> + +<p>Implement the update pages for the <code>BookInstance</code>, <code>Author</code>, and <code>Genre</code> models, linking them from the associated detail pages in the same way as our <em>Book update </em>page.</p> + +<p>A few tips:</p> + +<ul> + <li>The <em>Book update page</em> we just implemented is the hardest! The same patterns can be used for the update pages for the other objects.</li> + <li>The <code>Author</code> date of death and date of birth fields, and the <code>BookInstance</code> due_date field are the wrong format to input into the date input field on the form (it requires data in form "YYYY-MM-DD"). The easiest way to get around this is to define a new virtual property for the dates that formats the dates appropriately, and then use this field in the associated view templates.</li> + <li>If you get stuck, there are examples of the update pages in <a href="https://github.com/mdn/express-locallibrary-tutorial">the example here</a>.</li> +</ul> + +<h2 id="Summary">Summary</h2> + +<p><em>Express</em>, node, and third party packages on NPM provide everything you need to add forms to your website. In this article you've learned how to create forms using <em>Pug</em>, validate and sanitize input using <em>express-validator</em>, and add, delete, and modify records in the database.</p> + +<p>You should now understand how to add basic forms and form-handling code to your own node websites!</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="https://www.npmjs.com/package/express-validator">express-validator</a> (npm docs).</li> +</ul> + +<p>{{PreviousMenuNext("Learn/Server-side/Express_Nodejs/Displaying_data", "Learn/Server-side/Express_Nodejs/deployment", "Learn/Server-side/Express_Nodejs")}}</p> + +<h2 id="In_this_module">In this module</h2> + +<ul> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/Introduction">Express/Node introduction</a></li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/development_environment">Setting up a Node (Express) development environment</a></li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/Tutorial_local_library_website">Express Tutorial: The Local Library website</a></li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/skeleton_website">Express Tutorial Part 2: Creating a skeleton website</a></li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/mongoose">Express Tutorial Part 3: Using a Database (with Mongoose)</a></li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/routes">Express Tutorial Part 4: Routes and controllers</a></li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data">Express Tutorial Part 5: Displaying library data</a></li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/forms">Express Tutorial Part 6: Working with forms</a></li> + <li><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/deployment">Express Tutorial Part 7: Deploying to production</a></li> +</ul> + +<p> </p> diff --git a/files/ms/learn/server-side/express_nodejs/index.html b/files/ms/learn/server-side/express_nodejs/index.html new file mode 100644 index 0000000000..968f3e40e2 --- /dev/null +++ b/files/ms/learn/server-side/express_nodejs/index.html @@ -0,0 +1,77 @@ +--- +title: Express web framework (Node.js/JavaScript) +slug: Learn/Server-side/Express_Nodejs +tags: + - Beginner + - CodingScripting + - Express + - Express.js + - Intro + - JavaScript + - Learn + - NeedsTranslation + - Node + - Server-side programming + - TopicStub + - node.js +translation_of: Learn/Server-side/Express_Nodejs +--- +<div>{{LearnSidebar}}</div> + +<p class="summary">Express is a popular unopinionated web framework, written in JavaScript and hosted within the node.js runtime environment. The module explains some of the key benefits of this framework, how to set up your development environment and how to perform common web development and deployment tasks.</p> + +<h2 id="Prerequisites">Prerequisites</h2> + +<p>Before starting this module you will need to understand what server-side web programming and web frameworks are, ideally by reading the topics in our <a href="/en-US/docs/Learn/Server-side/First_steps">Server-side website programming first steps</a> module. A general knowledge of programming concepts and <a href="/en-US/docs/Web/JavaScript">JavaScript</a> is highly recommended, but not essential to understanding the core concepts.</p> + +<div class="note"> +<p><strong>Note</strong>: This website has many useful resources for learning JavaScript<em> in the context of client-side development</em>: <a href="/en-US/docs/Web/JavaScript">JavaScript</a>, <a href="/en-US/docs/Web/JavaScript/Guide">JavaScript Guide</a>, <a href="/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics">JavaScript Basics</a>, <a href="/en-US/docs/Learn/JavaScript">JavaScript</a> (learning). The core JavaScript language and concepts are the same for server-side development on Node.js and this material will be relevant. Node.js offers <a href="https://nodejs.org/dist/latest-v6.x/docs/api/">additional APIs</a> for supporting functionality that is useful in browserless environments, e.g. to create HTTP servers and access the file system, but does not support JavaScript APIs for working with the browser and DOM.</p> + +<p>This guide will provide some information about working with Node.js and Express, and there are numerous other excellent resources on the Internet and in books — some of these linked from <a href="http://stackoverflow.com/a/5511507/894359">How do I get started with Node.js</a> (StackOverflow) and <a href="https://www.quora.com/What-are-the-best-resources-for-learning-Node-js?">What are the best resources for learning Node.js?</a> (Quora).</p> +</div> + +<h2 id="Guides">Guides</h2> + +<dl> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/Introduction">Express/Node introduction</a></dt> + <dd>In this first Express article we answer the questions "What is Node?" and "What is Express?" and give you an overview of what makes the Express web framework special. We'll outline the main features, and show you some of the main building blocks of an Express application (although at this point you won't yet have a development environment in which to test it).</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/development_environment">Setting up a Node (Express) development environment</a></dt> + <dd>Now that you know what Express is for, we'll show you how to set up and test a Node/Express development environment on Windows, Linux (Ubuntu), and Mac OS X. Whatever common operating system you are using, this article should give you what you need to be able to start developing Express apps.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/Tutorial_local_library_website">Express Tutorial: The Local Library website</a></dt> + <dd>The first article in our practical tutorial series explains what you'll learn, and provides an overview of the "local library" example website we'll be working through and evolving in subsequent articles.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/skeleton_website">Express Tutorial Part 2: Creating a skeleton website</a></dt> + <dd>This article shows how you can create a "skeleton" website project, which you can then go on to populate with site-specific routes, templates/views, and databases.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/mongoose">Express Tutorial Part 3: Using a Database (with Mongoose)</a></dt> + <dd>This article briefly introduces databases for Node/Express. It then goes on to show how we can use <a href="http://mongoosejs.com/">Mongoose</a> to provide database access for the <em>LocalLibrary</em> website. It explains how object schema and models are declared, the main field types, and basic validation. It also briefly shows a few of the main ways you can access model data.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/routes">Express Tutorial Part 4: Routes and controllers</a></dt> + <dd>In this tutorial we'll set up routes (URL handling code) with "dummy" handler functions for all the resource endpoints that we'll eventually need in the <em>LocalLibrary</em> website. On completion, we'll have a modular structure for our route handling code, that we can extend with real handler functions in the following articles. We'll also have a really good understanding of how to create modular routes using Express.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/Displaying_data">Express Tutorial Part 5: Displaying library data</a></dt> + <dd>We're now ready to add the pages that display the <em>LocalLibrary</em> website books and other data. The pages will include a home page that shows how many records we have of each model type, and list and detail pages for all of our models. Along the way we'll gain practical experience in getting records from the database, and using templates.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/forms">Express Tutorial Part 6: Working with forms</a></dt> + <dd>In this tutorial we'll show you how to work with <a href="/en-US/docs/Web/Guide/HTML/Forms">HTML Forms</a> in Express, using Pug, and in particular how to write forms to create, update, and delete documents from the database.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/deployment">Express Tutorial Part 7: Deploying to production</a></dt> + <dd>Now you've created an awesome <em>LocalLibrary</em> website, you're going to want to install it on a public web server so that it can be accessed by library staff and members over the Internet. This article provides an overview of how you might go about finding a host to deploy your website, and what you need to do in order to get your site ready for production.</dd> +</dl> + +<h2 id="See_also">See also</h2> + +<dl> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs/Installing_on_PWS_Cloud_Foundry">Installing LocalLibrary on PWS/Cloud Foundry</a></dt> + <dd>This article provides a practical demonstration of how to install <em>LocalLibrary</em> on the <a href="http://run.pivotal.io">Pivotal Web Services PaaS cloud</a> — this is a full-featured, open source alternative to Heroku, the PaaS cloud service used in Part 7 of the tutorial, listed above. PWS/Cloud Foundry is definitely worth checking out if you are looking for an alternative to Heroku (or another PaaS cloud service), or simply feel like trying something different.</dd> +</dl> + +<h2 id="Adding_more_tutorials">Adding more tutorials</h2> + +<div> +<p>That's the end of the tutorial articles (for now). If you would like to extend it, other interesting topics to cover are:</p> + +<ul> + <li>Using sessions</li> + <li>User authentication</li> + <li>User authorisation and permissions</li> + <li>Testing an Express web application</li> + <li>Web security for Express web applications.</li> +</ul> + +<p>And of course it would be excellent to have an assessment task!</p> +</div> diff --git a/files/ms/learn/server-side/index.html b/files/ms/learn/server-side/index.html new file mode 100644 index 0000000000..b497257371 --- /dev/null +++ b/files/ms/learn/server-side/index.html @@ -0,0 +1,59 @@ +--- +title: Server-side website programming +slug: Learn/Server-side +tags: + - Beginner + - CodingScripting + - Intro + - Landing + - Learn + - NeedsTranslation + - Server + - Server-side programming + - Topic + - TopicStub +translation_of: Learn/Server-side +--- +<div>{{LearnSidebar}}</div> + +<p class="summary">The <strong><em>Dynamic Websites </em></strong>–<em><strong> Server-side programming</strong></em> topic is a series of modules that show how to create dynamic websites; websites that deliver customised information in response to HTTP requests. The modules provide a generic introduction to server-side programming, along with specific beginner-level guides on how to use the Django (Python) and Express (Node.js/JavaScript) web frameworks to create basic applications.</p> + +<p>Most major websites use some kind of server-side technology to dynamically display different data as required. For example, imagine how many products are available on Amazon, and imagine how many posts have been written on Facebook? Displaying all of these using completely different static pages would be completely inefficient, so instead such sites display static templates (built using <a href="/en-US/docs/Learn/HTML">HTML</a>, <a href="/en-US/docs/Learn/CSS">CSS</a>, and <a href="/en-US/docs/Learn/JavaScript">JavaScript</a>), and then dynamically update the data displayed inside those templates when needed, e.g. when you want to view a different product on Amazon.</p> + +<p>In the modern world of web development, learning about server-side development is highly recommended.</p> + +<h2 id="Learning_pathway">Learning pathway</h2> + +<p>Getting started with server-side programming is usually easier than with client-side development, because dynamic websites tend to perform a lot of very similar operations (retrieving data from a database and displaying it in a page, validating user-entered data and saving it in a database, checking user permissions and logging users in, etc.), and are constructed using web frameworks that make these and other common web server operations easy.</p> + +<p>A basic knowledge of programming concepts (or of a particular programming language) is useful, but not essential. Similarly, expertise in client-side coding is not required, but a basic knowledge will help you work better with the developers creating your client-side web "front end".</p> + +<p>You will need to understand "how the web works". We recommend that you first read the following topics:</p> + +<ul> + <li><a href="/en-US/docs/Learn/Common_questions/What_is_a_web_server">What is a web server</a></li> + <li><a href="/en-US/docs/Learn/Common_questions/What_software_do_I_need">What software do I need to build a website?</a></li> + <li><a href="/en-US/docs/Learn/Common_questions/Upload_files_to_a_web_server">How do you upload files to a web server?</a></li> +</ul> + +<p>With that basic understanding you'll be ready to work your way through the modules in this section. </p> + +<h2 id="Modules">Modules</h2> + +<p>This topic contains the following modules. You should start with the first module, then go on to one of the following modules, which show how to work with two very popular server-side languages using appropriate web frameworks . </p> + +<dl> + <dt><a href="/en-US/docs/Learn/Server-side/First_steps">Server-side website programming first steps</a></dt> + <dd>This module provides server-technology-agnostic information about server-side website programming, including answers to fundamental questions about server-side programming — "what it is", "how it differs from client-side programming", and "why it is so useful" — and an overview of some of the more popular server-side web frameworks and guidance on how to select the most suitable for your site. Lastly we provide an introductory section on web server security.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Django">Django Web Framework (Python)</a></dt> + <dd>Django is an extremely popular and fully featured server-side web framework, written in Python. The module explains why Django is such a good web server framework, how to set up a development environment and how to perform common tasks with it.</dd> + <dt><a href="/en-US/docs/Learn/Server-side/Express_Nodejs">Express Web Framework (Node.js/JavaScript)</a></dt> + <dd>Express is a popular web framework, written in JavaScript and hosted within the node.js runtime environment. The module explains some of the key benefits of this framework, how to set up your development environment and how to perform common web development and deployment tasks.</dd> +</dl> + +<h2 id="See_also">See also</h2> + +<dl> + <dt><a href="/en-US/docs/Learn/Server-side/Node_server_without_framework">Node server without framework</a></dt> + <dd>This article provides a simple static file server built with pure Node.js, for those of you not wanting to use a framework.</dd> +</dl> diff --git a/files/ms/learn/soalan_lazim/index.html b/files/ms/learn/soalan_lazim/index.html new file mode 100644 index 0000000000..b7fbc07a0f --- /dev/null +++ b/files/ms/learn/soalan_lazim/index.html @@ -0,0 +1,119 @@ +--- +title: Soalan-soalan lazim +slug: Learn/Soalan_lazim +translation_of: Learn/Common_questions +--- +<div>{{LearnSidebar}}</div> + +<p class="summary">This section of the Learning Area is designed to provide answers to common questions that may come up, which are not necessarily part of the structured core learning pathways (e.g. the <a href="/en-US/docs/Learn/HTML">HTML</a> or <a href="/en-US/docs/Learn/CSS">CSS</a> learning articles.) These articles are designed to work on their own.</p> + +<div> +<h2 id="Soalan-soalan_tentang_HTML_dan_CSS">Soalan-soalan tentang HTML dan CSS</h2> + +<p>Anda boleh cuba halaman <a href="https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto">Guna HTML untuk menyelesaikan masalah-masalah lazim</a> dan halaman <a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Howto">Guna CSS untuk menyelesaikan masalah-masalah lazim</a> bagi penyelesaian-penyelesaian biasa kepada masalah-masalah HTML/CSS.</p> +</div> + +<h2 id="Bagaimana_Web_berfungsi">Bagaimana Web berfungsi</h2> + +<p>Bahagian ini merangkumkan mekanikal web — soalan-soalan yang berkaitan pengetahuan umum tentang ekosistem Web dan bagaimana ia berfungsi.</p> + +<dl> + <dt> + <h3 id="Bagaimanakah_Internet_berfungsi"><a href="/en-US/docs/Learn/Common_questions/How_does_the_Internet_work">Bagaimanakah Internet berfungsi?</a></h3> + </dt> + <dd><strong>Internet</strong> adalah tulang belakang Web, infrastruktur teknikal yang membolehkan Web berfungsi. Pada asasnya, Internet adalah sebuah rangkaian besar yang merangkumi komputer-komputer yang berkomunikasi semuanya sekali. Artikel ini membincangkan bagaimana ia berfungsi, pada peringkat asasnya.</dd> + <dt> + <h3 id="Apakah_perbezaan_antara_halaman_web_laman_web_pelayan_web_dan_engin_carian"><a href="/en-US/docs/Learn/Common_questions/Pages_sites_servers_and_search_engines">Apakah perbezaan antara halaman web, laman web, pelayan web, dan engin carian?</a></h3> + </dt> + <dd>Dalam artikel ini kami menerangkan pelbagai konsep yang berkaitan dengan web: halaman web, laman web, pelayan web, dan engin carian. Istilah-istilah ini sering mengelirukan pendatang baru Web, atau digunakan secara tidak tepat. Mari kita belajar apa makna setiap istilah ini!</dd> + <dt> + <h3 id="Apakah_itu_URL"><a href="/en-US/docs/Learn/Common_questions/What_is_a_URL">Apakah itu URL?</a></h3> + </dt> + <dd>Dengan {{Glossary("Hypertext")}} dan {{Glossary("HTTP")}}, URL adalah salah satu konsep penting Web. Ia adalah mekanisme yang digunakan {{Glossary("Browser","browsers")}} untuk mendapatkan sumber yang telah diterbitkan di web.</dd> + <dt> + <h3 id="Apakah_itu_nama_domain"><a href="/en-US/docs/Learn/Common_questions/What_is_a_domain_name">Apakah itu nama domain?</a></h3> + </dt> + <dd>Nama-nama domain adalah bahagian penting daripada infrastruktur Internet. Mereka menyediakan alamat yang difahami manusia untuk mana-mana pelayan web yang ada di Internet.</dd> + <dt> + <h3 id="Apakah_itu_pelayan_web"><a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_web_server">Apakah itu pelayan web?</a></h3> + </dt> + <dd>Istilah "Pelayan Web" boleh merujuk kepada perkakasan atau perisian yang menyediakan laman web kepada klien-klien di seluruh Web — atau kedua-duanya berfungsi bersama-sama. Dalam artikel ini kami akan pergi ke bagaimana pelayan-pelayan web berfungsi, and kenapa ianya penting.</dd> + <dt> + <h3 id="Apakah_itu_hyperlink"><a href="/en-US/docs/Learn/Common_questions/What_are_hyperlinks">Apakah itu hyperlink?</a></h3> + </dt> + <dd>Dalam artikel ini, kita akan pergi ke apa itu hyperlink dan kenapa ianya penting.</dd> +</dl> + +<h2 id="Alatan_dan_tetapan">Alatan dan tetapan</h2> + +<p>Soalan-soalan yang berkaitan dengan alatan/perisian yang anda boleh gunakan untuk membina laman web.</p> + +<dl> + <dt> + <h3 id="Berapakah_kos_yang_diperlukan_untuk_membina_sesuatu_di_Web"><a href="/en-US/docs/Learn/Common_questions/How_much_does_it_cost">Berapakah kos yang diperlukan untuk membina sesuatu di Web?</a></h3> + </dt> + <dd>Anda mungkin tidak perlu membelanjakan apa-apa atau kos anda mungkin melambung tinggi. Dalam artikel ini kami membincangkan berapa banyak kos yang diperlukan untuk semua dan apa yang anda dapat hasil daripada apa yang anda bayar(atau anda tidak bayar).</dd> + <dt> + <h3 id="Apakah_perisian_yang_saya_perlukan_untuk_membina_laman_web"><a href="/en-US/docs/Learn/Common_questions/What_software_do_I_need">Apakah perisian yang saya perlukan untuk membina laman web?</a></h3> + </dt> + <dd>Dalam artikel ini kami menerangkan komponen-komponen perisian yang mana anda perlukan apabila anda mengedit, memuat naik, atau memaparkan laman web.</dd> + <dt> + <h3 id="Apakah_editor_teks_yang_ada"><a href="/en-US/docs/Learn/Common_questions/Available_text_editors">Apakah editor teks yang ada?</a></h3> + </dt> + <dd>Dalam artikel ini kami menekankan beberapa perkara apabila memilih dan memasang editor teks untuk pembangunan web. </dd> + <dt> + <h3 id="Bagaimanakah_untuk_saya_menetapkan_persekitaran_kerja"><a href="/en-US/docs/Learn/Common_questions/Set_up_a_basic_working_environment">Bagaimanakah untuk saya menetapkan persekitaran kerja?</a></h3> + </dt> + <dd>Apabila anda mengerjakan sebuah projek web, anda akan ingin untuk mengujinya di dalam persekitaran komputer anda sebelum anda tunjuknya ke dunia. Sesetengah jenis kod memerlukan sebuah pelayan untuk ujian, dan di dalam artikel ini kami akan menunjukkan anda bagaimana untuk menetapkan satu. Kami juga akan membahas bagaimana untuk menempatkan struktur berskala supaya fail-fail anda tetap tersusun walaupun projek anda berkembang besar.</dd> + <dt> + <h3 id="Apakah_alatan_pembangun_pelayar_web"><a href="/en-US/docs/Learn/Common_questions/What_are_browser_developer_tools">Apakah alatan pembangun pelayar web?</a></h3> + </dt> + <dd>Setiap pelayar web mempunyai satu set alat pembangun untuk menyahpepijat HTML,CSS dan kod web lain. Artikel ini menerangkan bagaimana untuk menggunakan fungsi-fungsi asas alat pembangun yang disediakan pelayar web anda.</dd> + <dt> + <h3 id="How_do_you_make_sure_your_website_works_properly"><a href="/en-US/docs/Learn/Common_questions/Checking_that_your_web_site_is_working_properly">How do you make sure your website works properly?</a></h3> + </dt> + <dd>So you've published your website online — very good! But are you sure it works properly? This article provides some basic troubleshooting steps.</dd> + <dt> + <h3 id="How_do_you_upload_files_to_a_web_server"><a href="/en-US/docs/Learn/Common_questions/Upload_files_to_a_web_server">How do you upload files to a web server?</a></h3> + </dt> + <dd>This article shows how to publish your site online with <a class="glossaryLink" href="https://developer.mozilla.org/en-US/docs/Glossary/FTP" title="FTP: FTP (File Transfer Protocol) is the standard network protocol for transferring files from one host to another over the Internet through TCP.">FTP</a> tools — one fo the most common ways to get a website online so others can access it from their computers.</dd> + <dt> + <h3 id="How_do_I_use_GitHub_Pages"><a href="/en-US/docs/Learn/Common_questions/Using_GitHub_Pages">How do I use GitHub Pages?</a></h3> + </dt> + <dd>This article provides a basic guide to publishing content using GitHub's gh-pages feature.</dd> + <dt> + <h3 id="How_do_you_host_your_website_on_Google_App_Engine"><a href="/en-US/Learn/Common_questions/How_do_you_host_your_website_on_Google_App_Engine">How do you host your website on Google App Engine?</a></h3> + </dt> + <dd>Looking for a place to host your website? Here's a step-by-step guide to hosting your website on Google App Engine.</dd> + <dt> + <h3 id="What_tools_are_available_to_debug_and_improve_website_performance"><a href="/en-US/docs/Tools/Performance">What tools are available to debug and improve website performance?</a></h3> + </dt> + <dd>This set of articles shows you how to use the Developer Tools in Firefox to debug and improve performance of your website, using the tools to check the memory usage, the JavaScript call tree, the amount of DOM nodes being rendered, and more.</dd> +</dl> + +<h2 id="Design_and_accessibility">Design and accessibility</h2> + +<p>This section lists questions related to aesthetics, page structure, accessibility techniques, etc.</p> + +<dl> + <dt> + <h3 id="How_do_I_start_to_design_my_website"><a href="/en-US/docs/Learn/Common_questions/Thinking_before_coding">How do I start to design my website?</a></h3> + </dt> + <dd>This article covers the all-important first step of every project: define what you want to accomplish with it.</dd> + <dt> + <h3 id="What_do_common_web_layouts_contain"><a href="/en-US/docs/Learn/Common_questions/Common_web_layouts">What do common web layouts contain?</a></h3> + </dt> + <dd>When designing pages for your website, it's good to have an idea of the most common layouts. This article runs thorugh some typical web layouts, looking at the parts that make up each one.</dd> + <dt> + <h3 id="What_is_accessibility"><a href="/en-US/docs/Learn/Common_questions/What_is_accessibility">What is accessibility?</a></h3> + </dt> + <dd>This article introduces the basic concepts behind web accessibility.</dd> + <dt> + <h3 id="How_can_we_design_for_all_types_of_users"><a href="/en-US/docs/Learn/Common_questions/Design_for_all_types_of_users">How can we design for all types of users?</a></h3> + </dt> + <dd>This article provides basic techniques to help you design websites for any kind of user — quick accessibility wins, and other such things.</dd> + <dt> + <h3 id="What_HTML_features_promote_accessibility"><a href="/en-US/docs/Learn/Common_questions/HTML_features_for_accessibility">What HTML features promote accessibility?</a></h3> + </dt> + <dd>This article describes specific features of HTML that can be used to make a web page more accessible to people with different disabilities.</dd> +</dl> |