Skip to content

Latest commit

 

History

History

02-style-tag

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
tutorial

02 Style tag in CSS

Another way to apply styles, is by using a <style> tag instead of the style property. You always have to follow these steps:

  1. Read the HTML and pick what element (tag) you want to decorate or apply styles to.

  2. Programmatically select the element you want to style using CSS Selectors.

  3. Write the styling that you want by using CSS property rules.

But make sure your CSS code is wrapped inside a <style> tag.

Look at this example:

<style>
    a {
        color: pink;
    }
</style>
<a href="https://google.com" target="_blank">Click me to open google.com</a>

We have an HTML anchor <a> that takes people to google.com when clicked. We use CSS to select all the anchor tags and make them pink.

📝 Instructions:

  1. Paste this code on your website to see the results.

💻 Preview:

It should look like this:

Style tag expected result