0

I am looking for a work around to add some css styling into my html tag. I do not want to edit the css file because I am using the particular formatting only once.

This is what I have tried and did not work out. I think the format is not being overridden by the css file.

<p margin-right ="3px" class="nav navbar-text navbar-right">Signed in as: @User.Identity.Name!</p>

How can I get it right?

1
  • 5
    You could do <p style="margin-right: 3px" ..., but you should avoid inline styles. Commented Sep 28, 2015 at 7:46

3 Answers 3

4

it's better to have it on a style.css file but it's like this:

<p style="margin-right:3px;" class="nav navbar-text navbar-right">
Sign up to request clarification or add additional context in comments.

10 Comments

Is it a good idea to edit the Bootstrap css file? i am not having a custom css file.
Please, NEVER edit the bootstrap.css, because if you have to download a new version of bootstrap, it will erase all the css you've done.
Even if I have only a single custom styling i should make a new css file right?
At least, do at the end of your php/html file: <style type="text/css"> //ALL YOUR CSS HERE </style>
I think that you have other elements with class = navbar-right. To add only to one element, use the ID. Add to your html <p id="MyModification"> And in your css #MyModification { margin-right:-200px }
|
0

You can try like this -

<p style="margin-right:3px" class="nav navbar-text navbar-right">
    Signed in as: @User.Identity.Name!
</p>

Comments

-2

You can create style at top i.e.

<style type='text/css'>
.mr3p {
    margin-right: 3px !important;
}
</style>

<p class="nav navbar-text navbar-right mr3p">

4 Comments

is it necessary that i add !important
Yes when you want to override some style then you need to apply !important.
Please, try not to use !important, it's always better to search from where is your problem than putting a !important.
Dont use !important - its evil. Let the styles cascade and use the appropriate scoping of selectors. !important should be reserved for emergencies (i.e. working with code where you cannot affect the emitted CSS)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.