![]() ![]() By describing the structure of our page we allow computer programs to understand it as well as humans.įor example most web browsers now have a “reader” mode. Third (and most importantly) semantic HTML is machine readable. Think how complicated a would be to build yourself! Machine-readable Built-in elements have lots of complex behaviours that are hard (or impossible) to reproduce. For example buttons not only respond when clicked, but also when the “Enter” or “Space” keys are pressed. You probably won’t remember to reproduce everything the browser does for you. Screenshot of this page with no CSS at all Complex behaviour This also means your page will still look okay if your CSS is broken or fails to load. Why re-create all of that from scratch when you could just override the bits you want to change. Sensible defaultsīrowsers have a bunch of built-in styles and behaviours you should take advantage of. ![]() There are a few reasons why using semantic HTML is important. You may wonder why it’s important for the browser to know what an element actually is, if it looks right and behaves the same. However from the browser’s perspective it has no meaning-it’s not actually a button. We could even add some JavaScript event handlers to it so it behaved like a button when clicked. It tells the browser what things are (rather than what content they contain or how they are styled).įor example we can make a look like a button using CSS: When we describe markup as “semantic” we mean it describes the structure of the document. This is useful because it let’s us communicate the “semantics” of the document. It is used to “mark up” a document with extra information about what each thing is. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |