This question already has answers here:
How to make my font bold using css?
(10 answers)
Closed 8 years ago.
Answers to this question show how to prepend/append text to a HTML element contents using CSS. Is there a way to make the CSS-added text bold without making the original HTML element contents bold as well?
Sure:
.OwnerJoe:before {
content: "Joe's Task:";
font-weight: bold;
}
Try:
#foo:after
{
content: 'hello!';
font-weight: bold;
}
Fiddle
Try this:
<div class="test">stuff</div>
.test{
border:1px solid #000;
}
CSS:
.test:before {
content: "more stuff";
background:red;
font-weight:bold;
}
Fiddle
All the information was in the link you posted, by the way. You just needed to add the font-weight to the right area.
That is of course possible
Just set appropriate styles to your pseudo element.
<span>World</span>
And the CSS:
span:before {
content: "Hello";
font-weight: bold;
}
Here's a working JSFiddle.
Related
This question already has answers here:
How to change the style of the title attribute inside an anchor tag?
(10 answers)
Closed 6 years ago.
I am trying to apply style for title attribute of a span tab. The span is already using a style class i want to use the same class to apply my style is it possible ?
<span class="span_class" title="100"> hello </span>
.span_class {
}
I want to change the background colour of the title.
the question is answered here: How to change the style of Title attribute inside the anchor tag?
alternatively, you should use a javascript library (there are several of them) like https://jqueryui.com/tooltip/
I think you should also add the aria-label attribute to ensure accessibility.
Can you use scss to have the same style? Something like that?
#mixin myclassforspan{
background:blue;
color:white;
padding:10px 2px;
}
.span_class[title] {
#include myclassforspan;
&:hover{
position: relative;
&:after{
#include myclassforspan;
content: attr(title);
position: absolute;
left: 0;
top: 100%;
z-index: 20;
}
}
}
This question already has answers here:
Add line break to ::after or ::before pseudo-element content
(8 answers)
Closed 6 years ago.
I am using the css after:: selecter to display texts. What I want to do is simply add a tag before this display. Cant get it to work
H2::after {
content: " <br>posted by me";
font-size: 14px;
}
<H2>Hello</H2>
you cannot add html tags inside content:"" of pseudo-element.
use display:block on the :after pseudo-element and you will get the desired result . see below :
H2::after {
content:"posted by me";
display:block;
font-size: 14px;
}
<H2>Hello</H2>
let me know if it helps
or you could use JQ if you REALLY want to include HTML tags
$("h2").after("<span style='color:red;font-style:italic'>posted by me</span>");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<H2>Hello</H2>
If you're looking to break the "::after" onto a new line why not add a "display:block" rule?
h2::after{
content:"posted by me";
font-size:14px;
display:block;
}
This question already has answers here:
Can you add line breaks to the :after pseudo element?
(4 answers)
Closed 7 years ago.
I need to place an i element that renders an icon, after a paragraph, but when I use the pseudo element "after" I only get pure html and not the icon. How can I get the icon rendering instead of the html text? Thank you.
.myDiv p:after {
content: '<i class="towerIcon"></i>';
}
RESULT
Lorem ipsum dolor sit amet, consectetur adipiscing<i class="towerIcon"></i>
You have to put the CSS value of the icon. In this example I use Font Awesome.
div p:after {
content: '\f002';
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
text-decoration: inherit;
margin-left:5px;
color:red;
}
Here is the fiddle : http://jsfiddle.net/uzu7u56h/1/
You can't render HTML in :after/:before pseudo selectors. What you can however do is style :after directly, for example:
.myDiv p:after {
content: '';
/* Other styling stuff here - optionally can put text into content property above too */
}
This question already has answers here:
Is there any way to make the HTML underline thicker?
(5 answers)
Closed 8 years ago.
I have some bold text and would like to underline to appear bold as well.
HTML
<p>Home Page</p>
CSS
p {
text-decoration: underline;
}
jsFiddle
I tried several thing but they didn't work well.
You can use border-bottom with some padding:
display:inline-block;
border-bottom:solid 2px red;
padding-bottom:2px;
JSFiddle
Edit:
To achieve the effect you want, you can wrap the text with a <span>: JSFiddle
One possible approach is to use pseudo-element :after to mimic border. Benefit in this case is that it's easy to control "border" offset with margin-top. For example:
p {
display: inline-block;
}
p:after {
content: '';
display: block;
height: 2px;
background: red;
margin-top: -1px;
}
<p>Home Page</p>
This question already has answers here:
How do I get this CSS text-decoration override to work?
(7 answers)
Closed 8 years ago.
Can we Disable underline of inside span element of underlined anchor tag. If it is possible please tell me how?
<a>hello<span>praveen</span</a>
<style type="text/css>
a{
text-decoration:underline;
}
a span{
text-decoration:none;
}
</style>
Try this.
add display: inline-block; for span style
a {
text-decoration:underline;
}
a span {
text-decoration:none;
display: inline-block;
}
http://jsfiddle.net/4oqyx6Le/2/
a > span {
text-decoration: none:
}