Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What mode do people use when using Emacs to edit web pages that contain CSS, javascript, and HTML?

Tags:

typically the code is something like:

<html>   <head>     <style type="text/css">        body { font-size:12pt; font-family: Arial;}         ....     </style>     <script type="text/javascript" src="jquery.1.3.2js"></script>     <script type="text/javascript">     <!--         $(document).ready(function(){           ...         });         ...     -->     </script>     <meta ... />   </head>   <body>     <div>       <p>        ....       </p>       ...     </div>     ....   </body> </html> 

I like javascript-mode for the syntaxt highlighting and indenting. Likewise for sgml-mode for the HTML. Also I get auto-complete on the open tags. Css-mode is not so important so it's not so much a priority.

That's 3 disparate languages and 3 modes. Right now I've been swapping modes manually as I edit different sections. This works, sort of.

Anyone got a better approach?

like image 284
Cheeso Avatar asked Dec 15 '09 18:12

Cheeso


People also ask

Can I use CSS inside JavaScript?

JavaScript can also be used to load a CSS file in the HTML document.

What is the role of CSSS in JavaScript language?

Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS describes how elements should be rendered on screen, on paper, in speech, or on other media.


1 Answers

Ever since web-mode came to existence, I have gotten rid of mumamo and nxhtml. web-mode is easier to use and install. For a start, it uses different syntax highlighting and indentation of a mixed js/html/css file. But for me the really handy thing about it is that it works in other templating languages. Here's an example configuration from their website:

(require 'web-mode) (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.jsp\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) 
like image 197
avendael Avatar answered Dec 08 '22 00:12

avendael