简体   繁体   中英

I'm learning CSS, How can i style a submit button using external css. I am trying something like this but i have no idea how to do this

how can i style a submit button using a external css file it is the code

<div class="bu">
<form action="#">
<button type="submit" class="but" value="submit">Log in</button>
</form>
</div>

 .but { background: lightBlue; padding: 10px; }
 <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="styles.css"> </head> <body> <div class="bu"> <form action="#"> <button type="submit" class="but" value="submit">Log in</button> </form> </div> </body> </html>

There are three ways we can use css to style your component

  1. Inline
  2. Internal
  3. External

These the ways are clearly explained in https://www.w3schools.com/html/html_css.asp

Since you are learning css , this also will hlep to you. https://www.webucator.com/article/how-to-create-a-css-external-style-sheet/

If you need an external style sheet,

  1. Create a style.css file
  2. Link that using style tag inside your html component head tag

firstly import the file at the top of the html file, like this: <link rel="stylesheet" href="mystyle.css"> . REPLACE mystyle.css with your file. After that in the css file, add ```.but`{}``, and finally add the style in the curly brackets.

Since you are getting started it will be much simpler to include the styles in the HTML. This is how you can embed CSS styles in HTML

 <style> button { color: read; background: green; padding: 5px; } </style> <div class="bu"> <form action="#"> <button type="submit" class="but" value="submit">Log in</button> </form> </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM