Coding Notes
Thread Topic: Coding Notes
-
I am taking a coding course online, and am going to post my notes here!
Just to have a place that I can come back to!
I also thought it would be helpful to post here in case anyone was interesting in coding and didn't know where to start! -
HTML (Hypertext Markup Language)-represents the content and structure of a webpage through the use of elements
Paragraph Element Example
To be inputted without spaces.
< p >Hello< / p >
< p > is the opening bracket
< / p > is the closing bracket
< is a left angle bracket (The other is a right angle bracket, but GTQ also won't let me put it in without trying to indent the content of this post)
/ is a forward slash
Hello is the content between the tags.
Some HTML elements do not have closing tags. These are called 'void elements'
Void Element Example
To be inputted without spaces
< img >
Void elements cannot have any content and only have a start tag. To display an image, you would need to include a couple of attributes inside the image element.
An 'attribute' is a special value used to adjust the behavior for an HTML element.
Example of Image Element with a Source (src) Attribute
To be inputted without spaces. Img src will always have a space though.
< img src = "image location" />
img is the tag name
src is the attribute name
"image location" is the attribute value
It should look like this:
The source (src) attribute is used to specify the location for that image.
An alt attribute provides alternative information for an image.
Example of Image Element with Source (src) and Alt Attributes
< img src ="example-cat-img-url" alt="cat sleeping in the grass" >
It should look like this:
If you learn coding in hopes of creating a website of your own, you will need to learn HTML, CSS and JavaScript.
HTML is for content and structure (or the base of a website)
CSS is for the styling of your website.
JavaScript is for interactivity of your website. -
An attribute is a value placed inside the opening tag of an HTML element. Attributes provide additional information about the element or specify how the element should behave.
Example of a Basic Syntax for an Attribute
< element atttibute="value" > < / element >
The attribute name is followed by an equal sign (=) and a value in quotes. The value can be a string or a number, depending on the attribute.
One of the most common HTML attributes is an href attribute. An href attribute is used to specify the URL of a link.
Example of an HREF Attribute
< a href = " > Visit our website < / a >
It should look like this:
Without the href attribute, the link would not work because there would be no destination URL.
Some of the most common attributes are src, alt and href.
Similar to the href attribute the src attribute is required because it specifies the image file to be displayed. The alt attribute is not required, but it is recommended for accessibility purposes.
The next example shows a checked attribute. These attributes are known for being unique.
Example of a Checked Attribute
< input type ="checkbox" checked / >
It should look like this:
In the example above, we have an input element with the type attribute set to checkbox. Inputs are used to collect data from users and the type attribute specifies the type of input. In this case, the input is a checkbox.
The checked attribute is used to specify that the checkbox should be checked by default. The checked attribute does not require a value. If the attribute is not present, the checkbox will be unchecked. That is known as the boolean attribute.
The boolean attribute represents true or false values.
There are several common boolean attributes in HTML, such as disabled, readonly and required. These attributes are used to specify the state of an element, such as whether it is disabled, read-only or required.
Post a reply as a guest or Log In
REMEMBER:
- Do not harass or insult other people. Treat others how you'd like to be treated.
View all 10 forum rules
- Do not harass or insult other people. Treat others how you'd like to be treated.
View all 10 forum rules