Why is a line displayed between these buttons? - html

How remove this line beetween buttons? First time I have this situation. Please look at my code here:
<a href="#info-section">
<button class="cta-btn rg">WATCH</button>
</a>
<a href="#info-section">
<button class="cta-btn lf">LEARN MORE</button>
</a>
My CSS responsive for buttons:
.cta-btn{
padding: 15px;
border-radius: 30px;
width: 150px;
font-size: .8em;
color: #fff;
background-color: inherit;
border: 1px solid #fff;
margin-top: 20px;
&:hover{
cursor: pointer;
}
}
.rg {
margin-right: 10px;
}
.lf{
margin-left: 10px;
}

I think that line is the underline of the A-tags.
Try adding text-decoration: none; to your <a>. Like this:
a {
text-decoration: none;
}
It could also be possible you forgot to close an A-tag before this part of your code. So check if every <a> has an closing </a>

I assume it's to do with the way you have the <a> tags surrounding the <button> but changing it to <button class="cta-btn rg">WATCH</button> removes the underline. It's almost as if there's a space character that it's formatting.
Note, this isn't the correct way to do it, but it removes the underline.

Related

How to Fix Button Background

I'm having trouble with fixing my button in CSS. I have my button styled correctly, but for some reason the background behind the button itself is white still.
The code for my button & links, as I think it may be an issue with my links as well.
HTML:
<button class="s1btn">
<a href="#" target="_blank" tabindex="1">GitHub
</a></button></div>
CSS for button:
.s1btn a {
text-decoration: none;
color: white;
background-color: #f36dcb;
border: black 1px solid;
border-radius: 3px;
text-align: center;
padding-top: 3px;
padding-left: 3px;
padding-right: 3px;
}`
.s1btn a:hover {
background: #844421;
}
.s1btn a:active {
background: #b36b43;
padding-top: 3px;
}
CSS for all links:
links {
font-size: medium;
margin-left: auto;
padding-right: 50px;
color: #844421;
font-weight: 500;
}
.hLink {
margin-right: 30px;
}
`
Screenshot of button:
Broken Button
I tried to comment out different sections of my button but that didn't help me target the problem to resolve the issue. I also tried to inspect the website itself, to figure out what was causing the background of my button to remain white.
Browsers have default styles for buttons, a tags, etc. Your css is only selecting the <a> tag in the <button> tag, so no styles are being applied to the <button> itself. You can reset the styles of the button with this:
button {
background: transparent;
border: none;
margin: 0;
padding: 0;
}
You can see more on resetting the button styles here: https://css-tricks.com/overriding-default-button-styles/

Having trouble linking a button

I'm only just learning html and have a question about linking a button. Could you tell me what I am doing wrong here?
</style>
<body>
<button onClick="name.html" class="button" ><span>name </span> </button>
<br>
In your application you should rather use an anchor link, because the button mostly used in forms. The corresponding HTML tag is <a>.
If you want to make your link look like a button you can give it a class and design it with CSS.
name
<style>
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
</style>

Why is my <button> not covering all the text inside it?

Basically, the button border is not covering all the text inside it.
How do I get it to cover all the text?
I have bootstrap installed and using it for some other components. Is it possible that bootstrap is interfering with this or something?
I have tried padding like many sites suggest, but it's not working.
<a target="_blank" href="/SignUp">
<button className="btn-design">Join BridgeBurma Today</button>
</a>
This is the css
.btn-design{
background-color: orange;
color: red;
text-align: center;
display: inline-block;
cursor: pointer;
border-radius: 20%;
white-space: nowrap;
}
Everyone shows you some CSS solutions but in my opinion the worst mistake with the code here is the nested button inside the a Tag. This doesn't make sense and should be avoided at all costs since they are for completely different, yet related functionality. Both trigger some action on click and combining them can lead to unpleasant side effects.
<a target="_blank" href="/SignUp">
<span classe="btn-design">Join BridgeBurma Today</span>
</a>
This would be a semantic valid HTML Markup, maybe you don't need span for this:
.btn-design{
background-color: orange;
color: red;
text-align: center;
display: inline-block;
cursor: pointer;
border-radius: 20%;
white-space: nowrap;
padding: 10px;
}
<a target="_blank" href="/SignUp" class="btn-design">
Join BridgeBurma Today
</a>
Remove Name in className and it'll work like charm, see below
.btn-design{
background-color: orange;
color: red;
text-align: center;
display: inline-block;
cursor: pointer;
border-radius: 20%;
white-space: nowrap;
}
<a target="_blank" href="/SignUp">
<button class="btn-design">Join BridgeBurma Today</button>
</a>

Add css to button

how could add css style to this button.
Button html:
<html>
<body>
<button onclick="myFunction()">Player</button>
<script>
function myFunction() {
alert('what ever');
}
</script>
</body>
</html>
CSS i want to add
<style>
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
If there is answered question, please send link. Thank you
You could add class="button" to the button to make it work. Cause your CSS .button will be used on every element which has the class="button"
function myFunction() {
alert('what ever')
}
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
<button class="button" onclick="myFunction()">Player</button>
Read more about how CSS Selectors work here
<button class="button" onclick="myFunction()">Player</button>
As your button class you've set it ".button" add "button" as a class like above
Anything you put after the . will match the name of the class in the element
https://css-tricks.com/the-difference-between-id-and-class/ explains how you use classes, ids and what they do in good detail
In your case, you're two solutions :
First : use classe, if you've differents buttons in your pages :
you can just add class attribute in your HTML element like that :
<html>
<body>
<button class="btn" onclick="myFunction()">Player</button>
<script>
function myFunction() {
alert('what ever');
}
</script>
</body>
</html>
And define the style in your class in your CSS :
<style>
.btn {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
Second : If all buttons are the same style, you can just add style for all element button :
Not change your HTML :
<html>
<body>
<button onclick="myFunction()">Player</button>
<script>
function myFunction() {
alert('what ever');
}
</script>
</body>
</html>
But, in your CSS, just change the reference, for select elements button :
<style>
button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
You can learn more explain about selector (.myClass, #myId, element) here in the mozilla developper website.
Don't forget, for optimize your web code, use as little code as possible, for reduce weight of pages, and to correctly use the different selectors (classes or id as not mandatory for CSS style : that depend to your utility) :)
Instead of declaring class button i.e(.button) you can apply style to all button elements.
Demo- https://jsfiddle.net/akshay193sw/bxm8wdqk/ Refer link
If you want to style a button I recommend adding a class to it and styling it with CSS. Here is an example below.
HTML Below
<button class='button_thing'> My Button </button>
CSS Below
.button_thing {
background-color: blue;
width: 180px;
height: 100px;
border-radius: 10px;
}
So what the CSS and HTML code above will do is it will create a blue button with a curved border and with a height of 100 pixels and width of 180 pixels. Now, the next question you might ask is how do I make an animation on the button when I hover over it?
CSS Hover Animations are a bit tricky at the start but get easier with practice. When I make buttons for my websites I like to use a site called ButtonAnimations because it gets straight to the point and gives me tons of animations (with HTML & CSS code) to choose from. Totally recommend it because it simply provides you with amazing buttons and animations that you can just copy and paste into your code. ButtonAnimations Website Link: ButtonAnimations - Create Spectacular Button Animations with HTML 7 CSS

Center tag works on link but not CSS or align attribute

I'm trying to center a button that is an <a> tag. However, the only thing that will work is the <center> tag. I've tried using <a style="text-align: center">Button</a> and <a align="center">Button</a>, but none of the two worked. Why is it that only the center tag works?
My CSS is this:
.btn {
color: white;
background-color: orange;
padding: 5px;
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
text-decoration: none;
transition: 200ms all;
}
.btn:hover {
background-color: #FFC964;
color: white;
cursor: pointer;
}
HTML:
Button
The <center> tag is deprecated and is most likely to be removed in all the browsers. And <a> tag is inline in nature, so text-align: center should be given for it's parent block element:
.make-center {text-align: center;}
<div class="make-center">
I am a link
</div>
In the above code, the <div class="make-center"> tag acts as a <center> tag.
Does your a element have the .btn class?
Try adding this CSS to it:
display:block;
margin:0 auto;
Otherwise, create a jsfiddle for us which reproduces the problem. You are not showing your entire CSS and markup.