Reputation: 7038
The emb
is not a class but an element. Can I use this element to style the div
or, the only way to do it is making emb
a class such as .emb
?
<div style=emb>
Hello
</div>
<style>
emb {
font-weight: 500;
font-style: italic;
background: transparent;
font-size: 18px
}
</style>
Upvotes: 0
Views: 68
Reputation: 3905
style=emb
is not a correct way to assign the class to an element.
To use an element to style inside div, you have to give it a class
or id
that maps the element to the style.css
where you define the styles. Also ,replace emb
with .emb
, you have to add .
decorator while using class
We have mainly 3 types of CSS decorators which we use to associate the HTML component with CSS component.
<div >
Hello
</div>
<style>
div {
font-weight: 500;
}
</style>
class
decorator with .
<div class="emb">
Hello
</div>
<style>
.emb {
font-weight: 500;
}
</style>
class
decorator with .
<div id="emb">
Hello
</div>
<style>
#emb {
font-weight: 500;
}
</style>
<div class="emb">
Hello
</div>
<style>
.emb {
font-weight: 500;
font-style: italic;
background: transparent;
font-size: 18px
}
</style>
<div id="emb">
Hello
</div>
<style>
#emb {
font-weight: 500;
font-style: italic;
background: transparent;
font-size: 18px
}
</style>
Upvotes: 0
Reputation: 273
You need to use emb as a class or id for styling your div tag and you can also use a separate css file.
<div class="emb">
Hello
</div>
<style>
.emb {
font-weight: 500;
font-style: italic;
background: transparent;
font-size: 18px
}
</style>
Here you can also use in-line css also.
<div style="font-weight: 500;
font-style: italic;
background: transparent;
font-size: 18px;">
Hello
</div>
Upvotes: 1
Reputation: 37
No, you cant use things like that to style element. Here, style is a attribute to div tag. You can use it directly to style your div.
<div style="font-weight: 500;
font-style: italic;
background: transparent;
font-size: 18px;">
Hello
</div>
But inorder to define class or id, you need to use class or id attribute. Or you can use tagname to style.
<div class='emb'>
Hello
</div>
<style>
.emb {
font-weight: 500;
font-style: italic;
background: transparent;
font-size: 18px
}
</style>
Upvotes: 0
Reputation: 1093
This is not how it works. You need to do e.g.:
<div class="emb">
Hello
</div>
<style>
.emb {
font-weight: 500;
font-style: italic;
background: transparent;
font-size: 18px
}
</style>
Upvotes: 0