How can I set the font-family & font-size inside of a div?
Asked Answered
H

2

17

This is my complete test html:

<!DOCTYPE>
<html>
    <head>
        <title>DIV Font</title>

        <style>
            .my_text
            {
                font-family:    Arial, Helvetica, sans-serif
                font-size:      40px;
                font-weight:    bold;
            }
        </style>
    </head>

    <body>
        <div class="my_text">some text</div>
    </body>
</html>

The font-family & font-size attributes are being ignored.

page result

Why? Why is font-weight used? What do I need to do so I can specify the font-family & font-size?

Thank you

Halona answered 11/9, 2015 at 19:21 Comment(1)
it is because you forgot to put semicolon after font-family: Arial, Helvetica, sans-serif.Micron
H
28

You need a semicolon after font-family: Arial, Helvetica, sans-serif. This will make your updated code the following:

<!DOCTYPE>
<html>
    <head>
        <title>DIV Font</title>

        <style>
            .my_text
            {
                font-family:    Arial, Helvetica, sans-serif;
                font-size:      40px;
                font-weight:    bold;
            }
        </style>
    </head>

    <body>
        <div class="my_text">some text</div>
    </body>
</html>
Hernandez answered 11/9, 2015 at 19:22 Comment(0)
T
4

Append a semicolon to the following line to fix the issue.

font-family:    Arial, Helvetica, sans-serif;
Taxexempt answered 11/9, 2015 at 19:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.