A: There are so many ways we structure text! In headings, bold or italicized, bullets or paragraph form, small or large fonts, etc. The key idea is to think about how a web page structures and utilizes text through the following languages: HTML, CSS, and Javascript. Understanding the relationship between these 3 texts, and later on, the relationship between HTML and Markdown, will help you get the bigger picture of this virtual “ecosystem” and help you work faster in this terrain.
A: HTML stands for Hypertext Markup Language. It defines the meaning and structure of web content, and is usually assisted by CSS and Javascript when building a website.
A: WYSIWYG stands for “What You See Is What You Get,” and it refers to text editors like Microsoft Word or Google Docs where users can edit and structure text without seeing the behind-the-scenes things occurring in the code of the app as it processes the changes the user is making on the blank document. Essentially, the users are using a given template to structure and design text as part of the editor’s functionality that is built into the app’s code.
A: The difference is that structuring and styling text becomes more explicit, more deliberate, and more detailed. Recognizing this is important, because all that we normally take for granted when writing on paper (i.e. spacing between lines) become things we must consciously put into code.
A: TextEdit is a text-only software that is similar to HTML, but when you drag an HTML document into a browser, the result may be different than what you have typed in your TextEdit file, because HTML requires more explicit instructions in the code to know, for example, when to skip lines or make something bold.
A: Terminal gives us the command line interface (CLI), allowing us to automate tasks on a computer without the use of a graphical user interface (GUI), because it is text-based. You may use terminal to send simple text commands.
A: A GUI is a set graphical icons that allows us to carry daily tasks. GUIs are most commonly seen in the layout of apps on phones: when you click on these apps to open then, you are interacting with a GUI and manipulating an underlying structure.
A: CSS, or Cascading Style Sheets, is used for styling the text in HTML. It is what you use to change the color, font size, etc. of your text to design your web page. It lets you style all elements of a type, class, or particular ID, so that you do not have to include (and manage) styling on every single element in your HTML.
A: Javascript, or JS, is a programming language that is capable of doing things, rather than only conveying structure. For example, JS turns a static browser into an interactive one by putting HTML and CSS “into motion.” For example, you can use JS to make the color of a line of text flash between blue and pink.
A: JS is similar to Terminal in that both dictate the functionality or behavior of their platforms (for JS, it is the functionality of a web page, and for Terminal, it is the functionality of a computer). It is important to remember that JS reads code line by line.
A: When you open Developer Tools in Chrome, you access two of several features of your browser, known as Elements and Console, that tell you crucial information about the web page you are currently on. Elements shows us the HTML elements of the page. Changes made in a remote HTML file will show up in Elements and alter your web page when that HTML file is dragged into your browser. Console lets us write Javascript.
A: The DOM is the Document Object Model that consists of the structure of elements on your web page. This structure is nested. Below is an example of a basic DOM.
A: All code is machine-readable, but not all code is human-readable. Humans can work with both types of code, but human-readable code is specifically tailored to the way humans read languages, which means it is more structured and clear or easy-to-follow (i.e. perhaps it contains instructions or comments throughout).
A: Wordpress and Squarespace are WYSIWYG editors, or “write your text only” editors, where you just fill in the templates, hit publish, and produce a web page. You are manipulating an underlying structure much like you do in Google Docs or Microsoft Word. Below the surface, Wordpress and similar platforms have compiled various packages and libraries (i.e. React) to form this easy-to-use, website-building template. On the other hand, we are building a web page without such templates. It is more like we are building a web page “from scratch,” but it is important to note that you are always manipulating something in coding.
A: The classifications “HIGH” and “LOW” level to a programming level refers to the level of abstraction of the language. For example, Javascript is a high level programming language because it is closer to a human language and is more human-readable than a low level language that is more machine-readable.
A: JavaScript provides Dot Notation for accessing the “members” of an “object”. Under dot notation, a member is accessed by giving the object’s name, followed by a period (or dot), followed by the member’s name. See the image below for an example of Dot Notation, specifically the HTML written below <script>
.
A: Code can be written in camelCase, kebab-case, snake_case, and more! camelCase is the more conventional case for the names of variables in Javascript, but people make different choices based on the task at hand, experience, or preference.
A: See the code below for the creation of a paragraph element.
// Create a paragraph element
var paragraph = document.createElement("paragraph");
// Insert text
paragraph.innerText = "this is a paragraph";
// Append <p> to <body>
document.body.appendChild(paragraph);
// Give your element a name
paragraph.id = “firstParagraph”
// Now, make your new paragraph element blue
paragraph.style.color = ‘blue’;
A: = is an “assignment operator” whereas == is a condition (means “equal to”).
A: Start by creating a blank HTML file from TextEdit. Drag that file into a web browser (Chrome). Next, open Developer Tools (command J). Then, follow the code below:
// Create a new 'p' element and assign it to the variable paragraphTag
var paragraphTag = document.createElement("p");
// This shows what is in the variable
console.log(paragraphTag);
// Add text to paragraphTag
paragraphTag.innerText = "Good Morning, America!";
// Add paragraphTag to Elements
document.body.appendChild(paragraphTag);
// Assign a color to the text in your paragraphTag. You can see this element appear in Elements & on web browser
paragraphTag.style.color = “blue”
// Make the text in your paragraphTag change color every 1 second
function changeColor () {
if (paragraphTag.style.color == “blue”) {
paragraphTag.style.color == “pink”;
} else if (paragraphTag.style.color == “pink”) {
paragraphTag.style.color == “blue”;
}
}
setInterval(changeColor, 1000);
A: Atom is a code editor. You can open both HTML and CSS in Atom, and you can use CSS and JS tags (<style>
and <script>
) “inline” in your HTML. You can also place the tags in separate files and link those files in the HTML. In Atom, the colored code and brackets help you know when your code is correct. The blue dot at the top of your file near its name means it is unsaved.
A: Commenting out something removes it from being put into motion without actually deleting it from your code. Essentially, it won’t be read. To comment out in HTML, use !--. To comment out in CSS, use /.../. To comment out in JS, use //. Commenting out is most commonly used when leaving instructions for your code (to make it more human-readable)!
A: When you edit your HTML file, the changes do not automatically show up on your web page. You must save those changes and then refresh your browser (command R) to see the updated web page. Additionally, when you are editing your web page in Console, those changes will not get saved anywhere, so make sure you add those changes to your HTML file.
A: Using a <script>
tag allows us to write Javascript inside an HTML file. See the code below for an example.
<script>
// Create new 'p' element and assign it to the variable newTag
var newTag = document.createElement("p");
// Add newTag to Elements
document.body.appendChild(newTag);
// Add text to newTag
newTag.innerHTML = "Today is sunny";
// Assign a color to newTag. In CSS, style modifications (i.e. color) to the variable are called attributes. You must define the style of the variable before you can use the changeColor function below.
newTag.style.color = “orange”
// Retrieve newTag via array. An array or list of p tags is listed from 0 to X (number).
var newTag = document.getElementbyTagName("p")[0]
// This shows you what is in the variable.
console.log(newTag);
// Make the text in your paragraphTag change color every 1 second
function changeColor () {
if (newTag.style.color == “orange”) {
paragraphTag.style.color == “purple”;
} else if (paragraphTag.style.color == “purple”) {
paragraphTag.style.color == “orange”;
}
}
setInterval(changeColor, 1000);
</script>
A: Markdown is a reduction of or a shorthand for HTML. For example, instead of closing something in an H1 tag, you would use # to mark the first heading (and ## for H2, ### for H3, all the way to H6, the smallest). Using Markdown helps us understand how our text will render in HTML without having to write HTML, but Markdown is missing more complicated features of HTML, so converting to HTML can be tricky, as it depends on the parser or Markdown to HTML converter. Some Markdown platforms include Stackedit, Dillinger, and Atom. The first two platforms allow you to see a preview of your Markdown file. Atom has a tool for viewing your markdown. Even Google Docs has a “Docs to Markdown” add-on that you can download.