Reputation: 57
By using the below code , i want to apply same effect of css on h1 and h2 tag.
HTML
<div class="blog_content_snippet">
<h1 contentEditable="true" data-text="Enter text here h1"></h1>
<h2 contentEditable="true" data-text="Enter text here h2"></h2>
</div>
CSS
.blog_content_snippet h1,h2:empty:not(:focus):before{
content:attr(data-text)
}
http://jsfiddle.net/cmta3bu5/6/
Using one css i want apply on both , anyone have idea ??
Upvotes: 0
Views: 81
Reputation: 12923
Declare both of them
.blog_content_snippet h1:empty:not(:focus):before,
.blog_content_snippet h2:empty:not(:focus):before{
content:attr(data-text)
}
Or you could always just create a class
and add it to whatever element you want:
HTML
<div class="blog_content_snippet">
<h1 class="content" contentEditable="true" data-text="Enter text here h1"></h1>
<h2 class="content" contentEditable="true" data-text="Enter text here h2"></h2>
</div>
CSS
.content:empty:not(:focus):before{
content:attr(data-text)
}
Upvotes: 1
Reputation: 2437
This may help you:
.blog_content_snippet h1:empty:not(:focus):before,
.blog_content_snippet h2:empty:not(:focus):before {
content:attr(data-text)
}
Upvotes: 0