HTML/Javascript

This code snippet shows how to perform different actions when Javascript is enabled or disabled. In this example, if Javascript is enabled, the add to cart button will show a pop-up message notifying the user that the item has been added. If, however, JS is disabled, it takes the user to “cart.html”.

<!doctype html>
<html>
<head>
	<title>demo</title>
</head>
<body>
	<a href="" id="add-to-cart" onclick="fun()"></a>
	<script>
		document.getElementById("add-to-cart").innerHTML="Add to Cart";
		function fun() {
			alert("Item Added!");
		}
	</script>
			                      
	<noscript>
		<a href="cart.html">Add to Cart</a>
	</noscript>
</body>
</html>

Html b- i- and strong- em-

Why don’t we use b- or i-tag in HTML? I thought <b>=<strong> and <i>=<em>, but apparently they are not.

Google tells me that <b> and <i> are actually explicit which is not what markup language are designed for. HTML should* only care about the Structure of a page instead of the Design. <b> and <i> are such that explicitly define what a certain part of text look like (particularly, bold and italic).

<strong> and <em> tags however, have a more semantic meaning. It is just by default of the browser rendering that <strong> and <em> appear bold and italic. It is possible to change the style later on.

With the technology these days, there are programs that reads the browser for people who can’t see. While the meaning of bold might be obvious to us who can see, strong and emphasis are more understandable to the blind people.

There are also some weaker arguments which says that <strong> and <em> is longer than <b> and <i>; Therefore, they have better visibility and are easier for the programmer too. But, … I don’t know. As a lazy programmer, I think it’s for the best that the commands are as short as possible for the sake of efficiency. Anyways, I consider this an invalid argument, but I guess you can think whatever.

Peace.

Sources: discussion from Udacity and StackOverflow