The HTML <style> tag and the class attribute

CSS

0 Comments

Example

<style>
	YOUR CSS CODE GOES HERE
</style>

<input type="button" class="btn" value="Button 1">
<input type="button" class="btn" value="Button 2">

The <style> tag – Holds all of your CSS code

The style tag holds all your CSS code (if you include the CSS directly in the HTML file). The style tag should be placed in the <head> section of your page. It's also possible to put your CSS in its own file (and that's actually the recommended method), but we'll explain how to do that later.

The class attribute – A way to label things you want styled the same

Notice that we added a new attribute called class to the buttons. Classes allow you to assign a label to similar elements (so that you can style them all the same). We gave our class a value of "btn", but that's just a name we made up.

We can now add this "btn" class to anything we want to look like our new button, such as <input type="submit"> or even links.

Leave a Comment