Apply a style Using an ID in CSS3

Apply a style Using an ID in CSS3

We can apply an id attribute to an HTML tag on your page to give it a unique identifier. We can then apply a style to that HTML tag using a special CSS selector for that tag. Using the id attribute to apply styles is an alternative to using the class attribute. See ” Apply a style using Class” for more about applying CSS classes.

We Can set your ID rules in an internal or external style sheet. To learn more about creating style sheets, see the sections: Create an internal style sheet” and ” Create an external style sheet”

Apply a style using an ID

Step 1: Inside the HTML tag to which you want to set an ID type id=”?”, replacing? with a unique identifier.

The identifier must begin with a letter and may be followed with letters, numbers, hyphens(-) underscores(_), and colons(:)

Step 2: In the Style sheet, type the name of the HTML tag.

Step 3: Type #? replacing? with the identifier, you assigned to the tag.

Step 4: Type{.

Step 5: Type the property-value pairs for the ID style separating multiple pairs with semicolons.

Step 6: Type }.

Result Output

<!DOCTYPE html>
<html>
    <Head>
        <Title>Coding thai</Title>
        <Style>
            h1#Heading{
                font-family: Arial;
                font-style: italic;
                color: red;
            }
        </Style>
    </Head>
    <body>
        <h1 id="Heading">Types of Web Developer</h1> 
        <h2>Fontend Developer and Back-end Developer</h2>
        <hr>
        <p>A front end developer has one general responsibility: to
          ensure that website visitors can easily interact with the page.
          Back-end developers are the experts who build and maintain the 
          mechanisms that process data and perform actions on websites.</p>
        <hr>
       <small> &copy;Copyright 2022 Codingthai</small>
    </body>
</html>

Follow us on Social Media For More

FacebookInstagramPinterest

Leave a Comment